RE: Space in regex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 20 November 2006 23:12, Richard Lynch wrote:

> . means *ANY* character, unless you escape it for PCRE
> 
> \. is what PCRE needs.

Not in a character class -- inside [], "." means ".".
 
> So, in PHP, to get the \ down to PCRE, you want 2 \:
> 
> Then there is the issue that '-' looks like a "range" character (A-Z
> etc) so you should put it at the end.
> 
> And there is no need to use the confusing (to me) ::xyz:: stuff...
> 
> '/[A-Za-z0-9\\'\\.& _-]/'

Except now you have a syntax error, as you've failed to notice (as did several others) that the \' in the original string is to escape the ' for PHP because the whole pattern string itself is single quoted.

> 
> You can simplify this a bit to:
> '/[A-Z0-9\\'\\.& _-]/i'

So the syntactically-correct simple version of this is '/[A_Z0-9\'.&_-]/i'.

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: m.ford@xxxxxxxxxxxxxx
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux