whats the regex for this expression ??
Moderator: General Moderators
whats the regex for this expression ??
what will be the regex for the string that contains only alphanumeric ,commma ,space .
Thanks in advance to all of you
Thanks in advance to all of you
Code: Select all
$regex = '/^[a-z0-9, ]+$/i';- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
No, it doesn't.aaronhall wrote:\n, just like always (it's got to be enclosed in double-quotes if you use the code above)
Code: Select all
[feyd@home]>php -r "$a = '#\n#'; echo preg_match($a,chr(0x0A));"
1I'm still not sure what you mean, but try this:
P.S Single quotes seem to work too. \n alone doesn't work for me while \n\r does.
Code: Select all
$regex = '/^[a-z0-9, \n\r]+$/i';- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Which is why PHP_EOS should be used for cross-platform applicationsOren wrote:I'm still not sure what you mean, but try this:
P.S Single quotes seem to work too. \n alone doesn't work for me while \n\r does.Code: Select all
$regex = '/^[a-z0-9, \n\r]+$/i';
- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
Indeed, thanksfeyd wrote:No, it doesn't.aaronhall wrote:\n, just like always (it's got to be enclosed in double-quotes if you use the code above)
Code: Select all
[feyd@home]>php -r "$a = '#\n#'; echo preg_match($a,chr(0x0A));" 1
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
we seem to be turning into a regex factory instead of a regex classroom...
play here: http://www.cuneytyilmaz.com/prog/jrx/
we're here if you get stuck
play here: http://www.cuneytyilmaz.com/prog/jrx/
we're here if you get stuck