whats the regex for this expression ??
Posted: Tue Apr 10, 2007 5:54 am
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
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
$regex = '/^[a-z0-9, ]+$/i';What do you mean by that?PHPycho wrote:whats the regex for newline.
\n, just like always (it's got to be enclosed in double-quotes if you use the code above)PHPycho wrote:whats the regex for newline.
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));"
1Code: Select all
$regex = '/^[a-z0-9, \n\r]+$/i';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';
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
You mean PHP_EOLJcart wrote:Which is why PHP_EOS should be used for cross-platform applications
or883 02 12313545
thanks in advance for help883-02-12313545
\n is actually part of the pattern so it doesn't. Hexadec such as \x0A work in single quotes in patterns too.aaronhall wrote:\n, just like always (it's got to be enclosed in double-quotes if you use the code above)PHPycho wrote:whats the regex for newline.