Would somebody please explain?

xtdn at levels.sait.edu.au xtdn at levels.sait.edu.au
Sun Apr 21 16:02:01 AEST 1991


rouben at math16.math.umbc.edu (Rouben Rostamian) writes:
>The command:
>    expr "Match" : "Ma"
>returns 2, as it should, since the first two characters of "Match" and "Ma"
>coincide.  Now, would somebody please explain why the command:
>    expr "match" : "ma"
>complains of a "syntax error"?

It is, as you suggest, because you are using a builtin command incorrectly.
I forget the exact details now, but I used often to suffer from similar
problems with arguments that looked like numeric expressions.  Anyway, the
point is that if you prefix the argument with something that makes it look
like nothing special, you won't suffer this type of problem.

So, for example, use:
   expr "xmatch" : "xma" - 1

David Newall, 16:32:56.04, Tuesday, 1991     Phone:  +61 8 344 2008
"Life is uncertain: Eat dessert first"       E-mail: xtdn at lux.sait.edu.au



More information about the Comp.unix.wizards mailing list