Janis Papanagnou <
[email protected]> writes:
$ echo "A%aB%bC%cX" |
awk '{ print match($0,/%[^auUlLcCsS%]/)
print substr($0,RSTART,RLENGTH) }'
5
%b
My (BSD) man page mentions
expr1 : expr2
The ``:'' operator matches expr1 against expr2, which must be a basic
regular expression. The regular expression is anchored to the begin-
ning 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 num-
ber of characters matched. If the match fails and the pattern con-
tains a regular expression subexpression the null string is returned;
otherwise 0.
I got concerned by "achored", tested
expr "A%aB%bC%cX" : "%[^auUlLcCsS%]"
and got a "0" returned, which is not what you want.
expr "A%aB%bC%cX" : ".*\(%[^auUlLcCsS%]\)"
returns "%b", though. So your mileage may vary.
Best regards
Axel
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)