RE: [PHP] preg_match problem

This is a discussion on RE: [PHP] preg_match problem within the PHP General forums, part of the PHP Programming Forums category; > if (preg_match('/^[A-Za-z0-9!@#$%&()*;:_.'\\/\\\\ ]+$/', $string)) > > Use single quotes and double back-slashes. PHP ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-23-2007
Beauford
 
Posts: n/a
Default RE: [PHP] preg_match problem


> if (preg_match('/^[A-Za-z0-9!@#$%&()*;:_.'\\/\\\\ ]+$/', $string))
>
> Use single quotes and double back-slashes. PHP strings also
> have escape sequences that use the back-slash as escape
> character, that's why you have to double them. And single
> quotes to avoid the $ character interpreted as the start of a
> variable.
>
> PS: Will we be risking going the perl way if we ask that PHP
> supported regular expressions natively (I mean: without
> having to provide them as strings)?


I have tried all the examples posted in the last couple of days, and none of
them, including the above work. Is there another solution to this, as this
just seems to be way to buggy?

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in
/constants.php on line 107

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in
//constants.php on line 107

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in
/constants.php on line 107

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in
/constants.php on line 107

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in
//constants.php on line 107

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in
//constants.php on line 107

Parse error: syntax error, unexpected ']' in //constants.php on line 107
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:50 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0