You are here: Regex - how to match until something « PHP Programming Language « IT news, forums, messages
Regex - how to match until something

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация