Welcome Guest, Not a member yet? Register   Sign In
Preg_match explained - Regex Help
#1

[eluser]richzilla[/eluser]
Hi all, Im having a bit of trouble getting my head around preg_match as im trying to write some customised validation functions.Basically im trying to validate a price, and what ive come up with so far is this:

Code:
[0-9]+(\.|\,)[0-9][0-9]

However, although that works, as far as i can see, the preg match function returns true if that is matched anywhere in a string, so you could enter complete rubbish:

Code:
aasosdoiasoi10.00idfgisdfgisudfgisdf

would still technically be correct. Is there any php function i can use to make sure my string exactly matches my regular expression?

any help would be appreciated.

Thanks
#2

[eluser]danmontgomery[/eluser]
use ^ for the start of a line, and $ for the end of a line
#3

[eluser]sophistry[/eluser]
great regex site: http://www.regular-expressions.info/




Theme © iAndrew 2016 - Forum software by © MyBB