[UPHPU] need regex help

District Webmaster webmaster at alpine.k12.ut.us
Wed Oct 13 10:55:57 MDT 2004


Thank you, that did it. I knew I was making it more difficult than I
needed to . . .

Dave 

>>> "Jon Jensen" <jjensen at debonairesolutions.com> 10/13/04 10:50 AM >>>
Try this:

if (preg_match("/[abc]/", $string)){
  //do something
}

If it's a range of characters (say, a-c and m-z), then you can do
something
like this:

"/[a-cm-z]/"

The way it works is that it will match any characters inside the
brackets,
including those that fall within any specified range. If you actually
wanted
to check for the '-' hyphen, you'd escape it with a backslash '\-' or
make
it the last character.

Jon





More information about the UPHPU mailing list