Re: Regex - how to match until something



veg_all@xxxxxxxxx wrote:
$string1 = preg_replace ( '/Hello.*(?!today)/', 'Hello ***' , $string1

$string1 = 'Hello world today';

'Hello world today' isn't followed by "today", so it returns true,

Read up on regexes.

Learn what (.*?) means.

$string1 = preg_replace ( '/Hello(.*?)( today)/', 'Hello ***\2' , $string1);

Grtz,
--
Rik Wasmus


.