php - preg_repalce matched partial data with correct regex -


this question has answer here:

$str = b c; $str = preg_replace("/a|b|c\","" $str); 

above regex matched a, b , c excluded. @ first thought caused gobal thing, after researched preg_match has default global enabled. has gone wrong?

you'll need quotes around string:

$str = "a b c"; 

...a comma between replacement text , source, , flip closing regex slash match opening one:

$str = preg_replace("/a|b|c/", "", $str); 

that leave $str set [space][space]


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -