regex - expr match problem in shell -
in sh shell script wrote following:
opr=+ echo `expr match "$opr" '[+\-x/]'` but error when ran:
expr: syntax error what doing wrong? same error when make opr equal - , / .
another interesting thing found when wrote this:
opr=a echo `expr match "$opr" '[+\-x/]'` it returns this:
1 this means matched string "a" 1 of +, -, x, , /. makes no sense!
first case: +
+ has special meaning expr:
+ token interpret token string, if keyword `match' or operator `/' second case: a
your regexp range operation, matching characters + x, includes alnums. make - matched literally in charclass, must first or last character; backslashing doesn't work.
Comments
Post a Comment