I want to replace all autonomous numbers from a string where the number has no adjacent characters (including dashes), for example:
Test 3 string 49Test 49test9 9
Should return test string 49Test 49Test9
So far I have played with:
$str = 'Test 3 string 49Test 49test9 9'; $str= preg_replace('/[^az\-]+(\d+)[^az\-]+?/isU', ' ', $str); echo $str;
However, with no luck, this returns
Test line 9Test 9test9
leaving part of the line, I thought to add [0-9] to the matches, but to no avail, what am I missing, seems so simple?
Thanks in advance
source share