Check for a numerical character

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
tyrant1337
Forum Newbie
Posts: 1
Joined: Mon Jul 24, 2006 6:12 am

Check for a numerical character

Post by tyrant1337 »

Hi,

Im trying to find out whether a value contains a numerical character in it

i.e. If FY1 1AL then ill do something with it or if its Bleakpool for instance I wont

The code ive found doesnt seem to work

Code: Select all

if(preg_match('[0-9]', $value))
Any comments would help

Cheers
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Try

Code: Select all

if (preg_match('#[0-9]#', $value))
Post Reply