Regex - how to match until something
- From: veg_all@xxxxxxxxx
- Date: 29 Apr 2006 13:46:31 -0700
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
.
- Follow-Ups:
- Re: Regex - how to match until something
- From: Mladen Gogala
- Re: Regex - how to match until something
- From: Rik
- Re: Regex - how to match until something
- Prev by Date: Re: to optimize a select join
- Next by Date: MYSQL table backups
- Previous by thread: to optimize a select join
- Next by thread: Re: Regex - how to match until something
- Index(es):