regex - regular expression in javascript string split, browser compatibility issue -


I am investigating this issue which only seems worse than I opened more deeply.

I started this expression fairly enough to split the string on the HTML 'br' tag:

  T = captions.innerHTML.split ( /  

It works in every browser (FF, Safari, Chrome) except IE7 and IE8, for example input input example:

  always Is subjective. & Lt; Br / & gt; Less frequently used warnings (maybe / perhaps) & lt; Br / & gt;  

Please note that in the example text there is a place before '/' and before a new line.

Each of the following will match all HTML tags in the browser:

T = Caption Creator HTML.split (/ & lt ;. *? & Gt; / g); T = caption Creator HTML.split (/ & lt; .. +? & Gt; / g); However, surprisingly (at least), not works in FF and Chrome:
  T = caption .innerHTML.split (/ & lt; Br / & gt;. / G);  

Edit:

It does not work on IE 7 or 8 (it has been suggested many times in the responses below):

  T = caption Player HTML.split (/ 
[^ & gt;] * & gt; / g);

(It worked on Chrome and FF.)

My question is: does anyone know an expression that matches the 'br' tag Works in all current browsers (but not the other HTML tags) and no one can confirm that the last example above should be a valid match because in the example before '>' there are two letters in the text.

PS - My performance is HTML transitional.

Edit:

I think I have proof that this is typical for string.split () behavior on IE, and not in general again. To see this problem you have to use split () I have also got a test matrix which shows a failure rate of about 30% of the case of partition when I run it on IE. In the same exam, 100% passed on FF and Chrome:

So far, I still have not found any solution for IE, and given by the author of that test matrix The library does not fix this issue.

Due because your code is not working because IE parses HDM and when you call it internal HTML If you read through the uppercase tag, for example, if you have HTML:

  & lt; Div id = 'box' & gt; Hello & lt; Br> World & lt; / Div & gt;  

And then you use this javascript (in IE):

  alert (document.getElementById ('box'). InnerHTML);  

You will get a warning box with this:

  Hello < BR & gt; World  

& lt; BR & gt; To fix this, now to make the regex insensitive, add i flag other than g flag and it will work as you expect.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -