Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: test if a parameter is numeric



On Tue, Feb 20, 2007 at 12:14:55AM +0000, Lydgate wrote:
> Sorry maybe I'm missing something, but if you need to match more than
> one digit, what's wrong with:
> 
> [[ "$1" == [0-9][0-9]* ]]

Lydgate,

shell script expressions != regex expressions.  The expression up there
would match:

00
01
02
03abc

but not:

1
2
3

However, I will give you that your expression would work fine in a regex
engine...

There is a ZSH extension that would have more of the effect you are
looking for but its as unportable as most other solutions,
unfortunately.

- Andy

-- 
Andrew Ruder <andy@xxxxxxxxxxx>
http://www.aeruder.net



Messages sorted by: Reverse Date, Date, Thread, Author