Forum Moderators: coopster

Message Too Old, No Replies

Regular expression match

ereg usage

         

Slait

2:09 pm on Oct 7, 2005 (gmt 0)

10+ Year Member



Sorry, I have the following dummy question:
So I get the number from html form and want to make
siple check. It should be no more then 3 digits number but can be less and should contain only digits of course,
so I'll try the following with ereg
ereg("[0-9]{3}") but it requires always only 3 digit number, but I want to check the 2 and 1 digit-numbers as well.For example 1 10 123 in one ereg expression? I found out that to use the is_numeric is possible, but it's only for numbers, and it's just interesting to know ,whether it's possible with ereg? Thanks

gliff

2:19 pm on Oct 7, 2005 (gmt 0)

10+ Year Member



[0-9]{1,3}

Slait

2:35 pm on Oct 7, 2005 (gmt 0)

10+ Year Member



Hi Gliff,
Of course i tried this but with Rex [0-9]{1,3}
the ereg() returns true for example for 2a or for 2aa and
only false for a22, so it's checks only first number. That's it!

gliff

4:24 pm on Oct 7, 2005 (gmt 0)

10+ Year Member



Misunderstood. Try

^[0-9]{1,3}$