[Solved] Find a match pattern of any digit and space with any character in a string and replace with | in PHP [closed]
$str = “COVId 1234 | SARS 4567 | EBOLA 2332”; preg_replace(‘([a-zA-Z]+ \d+ )’, ‘$0 |’, $str); echo $str; // COVId 1234 | SARS 4567 | EBOLA 2332 [a-ZA-Z]+ matches all alphabetic chars. is just to match a space. \d+ matches digits. Note the plural. 0 solved Find a match pattern of any digit and space … Read more