0

I have the following HTML code and am trying to get data using RegExp. This does not work in mobile browsers.

var JSON:

 <div class="comment_item right">
<div class="comment_author_wrap">
    <div class="comment_author">
    </div>
</div>
    <p mid="1369">fdsfds
    </p>

Variable json is the response from the server.

Regexp:

 msg = json;
 var regexp = /<p(.*?)<\/p>/gms;
 result = msg.match(regexp);
fomadoor
  • 3
  • 1
  • 1
    https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 – Phix Oct 02 '18 at 22:25

1 Answers1

0

The 's' modifier is not supported by many browsers!

I suggest you change your regex to:

/<p[\s\S]*?</p>/g

That should work in all browsers.

What it does: It starts by matching '<p', then it matches any characters (including newline) any number of times until the string '</p>' occurs.

Poul Bak
  • 10,450
  • 5
  • 32
  • 57