Page 1 of 1
Character Classes
Posted: Thu May 17, 2007 11:46 pm
by nwp
[abc] matches a, b or c so
[home] matches h, o, m OR e
But I wanna match the compleate word "home"
How can I do it ??
Posted: Fri May 18, 2007 4:21 am
by stereofrog
/home/ matches "home"
Please do read documentation I linked to in the other thread.
http://www.php.net/manual/en/reference. ... syntax.php
Posted: Fri May 18, 2007 5:13 am
by nwp
Ya I've read that I actually need something like this
(\d+?)([^home|^House]+?)(\d+?)
e.g. Match -> 58hello98 not 45house85 not 15home45
Posted: Fri May 18, 2007 5:46 am
by stereofrog
Code: Select all
$s = array("58hello98", "45house85", "15home45", "77blah88");
$r = "/(\d+)(?!house|home)\D+(\d+)/";
print_r(
preg_grep($r, $s)
);
have a read about lookaheads there.