0

I have a JavaScript and I must to use regex to extract my wanted parts with php.

my javascript is:

gabjoorblock += '<div class="ganjoor-poem-block">';
gabjoorblock += '<div class="ganjoor-m1">یونیکد</div>'; 

I try this code to retrieve "یونیکد" but it don't work:

The code should be this:

$regex = '/<div class="ganjoor-m1">(.+?)<\/div>/s';

please help me.

Ehsan
  • 2,273
  • 8
  • 36
  • 70
  • 5
    You shouldn't parse HTML with regex if you don't want head banging bugs: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags#answer-1732454 :/ That may be linked. If the HTML is just what you show, your regex is working. – Robin Feb 17 '14 at 16:56
  • 1
    '/
    ([^<]*)<\/div>/s';
    – philipp Feb 17 '14 at 16:58
  • [`strip_tags()`](http://il1.php.net/strip_tags) is your friend! – Lix Feb 17 '14 at 16:58
  • @philipp it don't work – Ehsan Feb 17 '14 at 17:03
  • On the snippet you gave, it works. What is your full gabjooblock string? How do you apply your regex? Have you considered using the dom to retrieve what you want? – Robin Feb 17 '14 at 17:15

0 Answers0