Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expression help

Status
Not open for further replies.

litton1

Technical User
Apr 21, 2005
584
GB
hi all,
how can I check for a blank space in this pattern ?
Code:
$pattern = "/\band\b|\bor\b|[\'\#\=\+\"\%\$\!\,\]]/i";

A problem with no solution is a problem viewed from the wrong angle
 
It's fairly easy, since you are using a character class:
Code:
$pattern = "/\band\b|\bor\b|[ '#=+\"%$!,\]]/i";
Inside the char class definition the space itself is sufficient. ALso, there is no need to escape meta characters inside a char class definition unless they would interfere with the syntax of the whole expression. Therefore, just the right square bracket and the double wuote need escaping.
 
thanks for the amendments and info, that worked great!

A problem with no solution is a problem viewed from the wrong angle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top