0

I want to have One part multiline in a regex

<?php
 function bloggerLoop ( $matches ) { print_r ( $matches ) ; }

 $theme = preg_replace_callback(
         "#<b:loop values='data:(.*)' var='(.*)'>(.*?)</b:loop>#i",
         "bloggerLoop", 
         $theme 
         );
?>

This is what I have, but b:loop is more than once in the template and this regex skips all the loops and make one "big" loop, but i only need to have one "part".

What need is:

<b:loop values='data:x' var='x'>MULTILINE</b:loop>

The file what is needed to be parsed is: http://pastebin.com/a3g3G1uE

I hope you can help me with the regex.

Tanks.

-Wesley

1 Answer 1

1

Regex is not the tool for this. HTML tag structure is too complex, for basic Regex, and you should try some HTML DOM library like PHP Simple HTML DOM Parser, to do HTML DOM work.

$html = file_get_html('http://pastebin.com/raw.php?i=a3g3G1uE');
foreach($html->find('b:loop') as $element)
       echo $element->values. '<br>';

Look at my example for your specific case and read documentation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.