|
Posted by veg_all on 04/29/06 23:46
How do you replace an occurence until a certain point: You can see my
example code below and the output:
$string1 = 'Hello world today';
$string2 = 'Hello blahblah';
$string1 = preg_replace ( '/Hello.*(?!today)/', 'Hello ***' , $string1
);
$string2 = preg_replace ( '/Hello.*(?!today)/', 'Hello ***' , $string2
);
echo "$string1 - This should be Hello *** today\n";
echo "$string2 - This is correct\n";
Outputs:
======
Hello *** - This should be Hello *** today
Hello *** - This is correct
Navigation:
[Reply to this message]
|