help-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

expr, regular expressions and '^' ...


From: aekalman
Subject: expr, regular expressions and '^' ...
Date: 17 Nov 2004 20:41:39 -0800

Hi All.

expr has the following behavior with string expressions:

`STRING : REGEX'
     Perform pattern matching.  The arguments are coerced to strings
     and the second is considered to be a (basic, a la GNU `grep')
     regular expression, with a `^' implicitly prepended.  The first
     argument is then matched against this regular expression.

Is there any way for me to suppress the implicitly prepended '^' in
the regex? E.g. I have

expr 'sfiaravrt-7s-sf' : '\(-7s\)'

and it fails because -7s is not at the start of the string. How can I
use expr (or something else entirely) to return what you would get if
a '^' were not explicitly prepended, i.e. '-7s'?

Thanks,

--Andrew Kalman
aek at pumpkin inc dot com


reply via email to

[Prev in Thread] Current Thread [Next in Thread]