Re: Regex - how to match until something
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: Regex - how to match until something

From: Rik <luiheidsgoeroe@hotmail.com>
Date: Sun Apr 30 2006 - 02:55:54 CEST

veg_all@yahoo.com 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
Received on Mon May 1 03:07:36 2006