如何使用正则表达式从列表中排除名称?
数据:
$subject=
"Damon Carson Stovall,
Bret Roman Mikulak,
Jack Filiberto Quirke,
Elroy Forrest Jarnagin,
Ulysses Wiley Cregger,
Brent Greg Jonah,
Bret Armand Daylong,
Ned Numbers Vandell,
Bret Alden Cutlip,
Bret Chung Markie,";
正则表达式:
// Select anyone with the first name of Bret
$pattern = "/Bret /";
我目前的解决方案:
// Loop through & Skip any line that matches Bret.
$subject_array = explode(",",$subject);
foreach($subject_array as $line)
if(!preg_match($pattern, $line))
echo "$line<br>";