On Tue, 11 Feb 2003, Gordon wrote:

> Robert P. J. Day wrote:

> > $ man expr
> > 
> >   the "expr" utility is, IMNSHO, sadly overlooked.
> > 
> > rday
> > 
> > 
> > 
> Thanks for the suggestion. I figured out that I can use
> 
> $ expr match $var "[0-9]*$"
> 
> and it will return >=1 for a valid integer and 0 for an invalid string.

what it's returning (and i'm sure you already noticed this) is
the length of the match.  by default, the match is *already* anchored
to the front of the string, so you correctly just anchored it to 
the end to make sure you covered the entire string.

and the matching also supports \( \)-style tagging a la Perl,
so you can get the actual match itself.

like i said: expr -- a sadly overlooked utility.

rday



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to