PHP and Regex if word found -


i'm looking perform strip of characters if word found in string, if word numbers matched regex perform strip actual numbers 0-9 or preg replace them nothing, btw numbers wrapped in "". best way put these 2 functions together? example if data man, numbers fun! "123abc" return man, numbers fun! "abc" if numbers isn't present ignored.

i feel of answers here overcomplicated. maybe it's me, should need:

if (stripos($str, 'numbers') !== false) {     $str = preg_replace('/\d/', '', $str); } 

edit: if want numbers inside quotation marks, might able regex, i'd way:

if (stripos($str, 'numbers') !== false) {     $arr = explode('"', $str);      ($i = 1; $i < count($arr); $i += 2) {         $arr[$i] = preg_replace('/\d/', '', $arr[$i]);     }      $str = implode('"', $arr); } 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -