1

I have a lot of difficulties in this REGEX stuff, can any one help improve my code? Thank you in advanced.

What I need is to get the content in side the [Slide] CONTENT [/Slide] tags. What i am doing is:

preg_match ('/\[Slide\].*\[\/Slide\]/s', $content, $matches);
$conteudo_slide = $matches[0];

$conteudo_full = preg_replace('/\[Slide\]/s', "", $conteudo_slide);
$conteudo_full = preg_replace('/\[\/Slide\]/s', "", $conteudo_full);

the content of the page is:

<p>[Slide]http://www.gprco-cpa.com/images/industries/corporations.jpg[/Slide]</p>
<p>[Slide]http://www.expatcpa.com/Corporation_HQ.jpg[/Slide]</p>
<p><br />[Slide]</p>
<p><a href="http://localhost/~tiago/main_wordpress/?attachment_id=437" rel="attachment wp-att-437">
<img class="alignright size-full wp-image-437" title="lightbulb"src="http://localhost/~tiago/main_wordpress/wpcontent/uploads/2012/09/lightbulb1.jpg" alt="" width="500" height="334" /></a>[/Slide]</p><p>&nbsp;</p>
<p>[Slide]http://www.youtube.com/watch?v=SHVOyGVQ3Tw&amp;feature=g-all-u[/Slide]</p> 

Isn´t any more correct way of doing this? Thank you.

1 Answer 1

2

try adding ():

preg_match ('/\[Slide\](.*?)\[\/Slide\]/s', $content, $matches);
Sign up to request clarification or add additional context in comments.

2 Comments

<p>[Slide]gprco-cpa.com/images/industries/corporations.jpg[/Slide]</p> <p>[Slide]expatcpa.com/Corporation_HQ.jpg[/Slide]</p> <p><br />[Slide]</p> <p><a href="localhost/~tiago/main_wordpress/?attachment_id=437" rel="attachment wp-att-437"><img class="alignright size-full wp-image-437" title="lightbulb" src="localhost/~tiago/main_wordpress/wp-content/uploads/2012/09/…" alt="" width="500" height="334" /></a>[/Slide]</p> <p>&nbsp;</p> <p>[Slide]youtube.com/watch?v=SHVOyGVQ3Tw&amp;feature=g-all-u[/…>
preg_match ('/[Slide](.*?)[\/Slide]/s', $content, $matches); WORKED!! Thank you very much!

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.