Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I would like find all occurences of "ABC" which are not followed by "123"
and replace them with "abc". For example:
"ABC dd"  ->  "abc dd"
"ABC123"  ->  "ABC123"
"ABC 123" ->  "abc 123"

Give me a recipe, please. I've spent 2 hours googling for it.


Re: ereg_replace

Tomek Toczyski wrote:
Quoted text here. Click to load it

preg_replace_callback() is your friend. Use preg_replace_callback().


function lowercase_callback($m) {
    return strtolower($m[0]);

$s = preg_replace_callback('/[A-Z]+(?![A-Z\d])/', 'lowercase_callback',

Re: ereg_replace

Chung Leong:
Quoted text here. Click to load it

It works. Thanks a lot.

Re: ereg_replace

This will find the files you specified:
(^[A][B][C]) ([1-9a-zA-Z]*)

I tried finding the right substitution syntax, but didn't really find a  
solution.  It looks like maybe using tr/ to translate between the UC and LC  
would be a start.  Look at
Unfortunately I don't have BASH on this computer so I can't really work more  
on this.


Quoted text here. Click to load it

Site Timeline