|
Posted by "Richard Lynch" on 10/25/05 05:08
On Mon, October 24, 2005 3:59 pm, Shaun wrote:
> I am trying to create a regular expression for a width of a room, the
> value
> can be a whole integer (up to 999) with up to 2 decimal places -when
> it is
> stored in the database mysql will pad the value accordingly.
>
> /^[0-9]{1,3}.?[0-9]{0,2}?$/
Because '.' is special to preg, this expression ALSO matches:
12a25
5z43
7a
[aside]
Engineer: 7A, please.
Davey: What number, please?
Band: 7A!
Davey: All right, okay, just cuz I'm short
[/aside]
This might (or might not) do it:
/^[0-9]{1,3}(\\.[0-9]{1,2})?$/
The \\ is there so that PHP will turn it into \, and then you have \.
in the regular expression which the PRCE will interpret as "the
literal character known as 'dot'" instead of "any old character at
all"
> Also is there any difference between [0-9] and \d
Try it and see.
--
Like Music?
http://l-i-e.com/artists.htm
Navigation:
[Reply to this message]
|