original string: $text = "aaaa aaaasomething someaaaa aaaa 89aaaa aaaathis"
final result i need: $textresult = "aaaa aaaasomething some4a aaaa 894a aaaathis"
I mean: I want to replace any string on the text that ends with aaaa to 4a. But only if it is an ending and not an isolated string like aaaa or a string that starts with aaaa.
I presume str_replace or preg_replace could eventually do this in a single code line but do not have idea how to do it.
Thanks in advance!
\Bonly matches between two alphanumeric characters, i. e. in the middle of a word.\bonly matches between alphanumeric and non-alphanumeric characters, i. e. at the start or end of a word.