[…] and I found that\+
is. […]
Obsolete (“basic”) regular expressions differ in several respects.|
is an ordinary character and there is no equivalent for its functionality.+
and?
are ordinary characters, and their functionality can be expressed using bounds ({1,}
or{0,1}
respectively).
Yes it does. Because it is described in the manual:expr(1) does not evaluate regexps. It evaluates arithmetic expressions. Why would you think it should honor regexps?
expr1 : expr2
The ":" operator matches expr1 against expr2, which must be a
basic regular expression. The regular expression is anchored to
the beginning of the string with an implicit "^".
If the match succeeds and the pattern contains at least one
regular expression subexpression "\(...\)", the string
corresponding to "\1" is returned; otherwise the matching
operator returns the number of characters matched. If the match
fails and the pattern contains a regular expression subexpression
the null string is returned; otherwise 0.
This works:Yes it does. Because it is described in the manual:
Code:expr1 : expr2 The ":" operator matches expr1 against expr2, which must be a basic regular expression. The regular expression is anchored to the beginning of the string with an implicit "^". If the match succeeds and the pattern contains at least one regular expression subexpression "\(...\)", the string corresponding to "\1" is returned; otherwise the matching operator returns the number of characters matched. If the match fails and the pattern contains a regular expression subexpression the null string is returned; otherwise 0.
slippy$ expr "Hello 7.1" : '..* \([.0-9][.0-9]*\)'
7.1
slippy$
slippy$ gexpr "Hello 7.1" : '..* \([.0-9][.0-9]*\+\)'
7.1
slippy$