[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 ??
Character Classes
Moderator: General Moderators
- stereofrog
- Forum Contributor
- Posts: 386
- Joined: Mon Dec 04, 2006 6:10 am
/home/ matches "home"
Please do read documentation I linked to in the other thread.
http://www.php.net/manual/en/reference. ... syntax.php
Please do read documentation I linked to in the other thread.
http://www.php.net/manual/en/reference. ... syntax.php
- stereofrog
- Forum Contributor
- Posts: 386
- Joined: Mon Dec 04, 2006 6:10 am
Code: Select all
$s = array("58hello98", "45house85", "15home45", "77blah88");
$r = "/(\d+)(?!house|home)\D+(\d+)/";
print_r(
preg_grep($r, $s)
);