View Full Version : regular expressions

01-12-2006, 12:48 AM
Hello everybody,

I'm trying to make a function, that finds all strings like "{SOMETHNG:somethingmore}" from HTML-file.

I tried this:

$str="asdas sd,{INCLUDE_HTML:kall.htm}asd jes jes yehhh sad {INCLUDE_HTML:moon.htm}kall ekpas asda ";
$str_two="<html><head><title>my page</title>{INCLUDE_HTML:stuff}</head><body>weolcome!!!!<hr> {INCLUDE_HTML:baaad.htm} </body></html>";
if(preg_match_all("/\{INCLUDE_HTML:\w+}\b/",$str,$array)) {

it found only from first string, bot from the second one it didnt find anything...

but it doesnt find all the occurences and seems strange... has somebody a better idea to do this?

ralph l mayo
01-12-2006, 05:59 AM
$array[0] will be the total match, $array[1] will be just the stuff after the colon

or, if you're doing multiple tags in the same format,
$array[0] will be the total match, $array[1] will be the stuff before, and $array[2] the stuff after the colon

01-12-2006, 08:01 AM
thank you very much, your version works much better:thumbsup: