daneyul
2006-11-29 16:35:13 UTC
Examples on regexp seem to be always missing the case of an asterisk at
the front of the expression. How is that handled? Here's what I get:
% set x *123
*123
% regexp $x 123
couldn't compile regular expression pattern: quantifier operand invalid
So...I tried preceding the variable with the asterisk with a period
(matches any single char)
% regexp .$x 123
1
That seems to work ok, but if I then make a variable without the
asterisk...
% set x 123
123
The preceding period no longer works...
% regexp .$x 123
0
I know this is probably simple, but all examples seem to be missing the
proper procedure here and I'm a regexp novice. How would I accomplish
the above (ie, formulate an regexp that would handle a variable with or
without an asterisk wild card anywhere within it)?
-Daniel
the front of the expression. How is that handled? Here's what I get:
% set x *123
*123
% regexp $x 123
couldn't compile regular expression pattern: quantifier operand invalid
So...I tried preceding the variable with the asterisk with a period
(matches any single char)
% regexp .$x 123
1
That seems to work ok, but if I then make a variable without the
asterisk...
% set x 123
123
The preceding period no longer works...
% regexp .$x 123
0
I know this is probably simple, but all examples seem to be missing the
proper procedure here and I'm a regexp novice. How would I accomplish
the above (ie, formulate an regexp that would handle a variable with or
without an asterisk wild card anywhere within it)?
-Daniel