hi!
i need to find the text between FIRST and LAST <block> and </block> tag.
i think preg_match is the right function:
this version doesn't work:
preg_match("|<block[>]+>(.*)</block[>]+>|U", $block, $match);
Regexp damages my brain...
You was so close...
Try something similar with next code. <?php $stringTags =\"<BlocK >| text1<blocK> tex2 |</block></blocK >\";
preg_match(\"|<block[>]>(.)</block[>]*>|i\", $stringTags, $match); print_r($match); // print_r works with PHP > = 4, I think ?>
DON\'T FORGET: View Source
Thanks Marcel!
Worked superfine, there's only one thing i couldn't get to work, i tried to add newline support for the script, but as i said before - regexp is killing my brain π
preg_match("|<block[>]>+((.)\n\r)+</block[>]*>|i", $block, $match);
i'd appreciate any helpπ
maybe `s' modifier is what you want... something like: <?php $stringTags ="<BlocK >| text1<blocK> \n tex2 |</block></blocK >";
preg_match("|<block[>]>(.)<\/block[>]*>|is", $stringTags, $match); ?>
Now should be more than `superfine' π