What is the difference between these regular expressions: replaceable?
((?:[^\"])*) ([^\"]*)
background to this question:
The WYSIWYG javascript editor (tinymce) cannot parse my html code in Firefox (23.0.1 and 25.0a2), but it works in Chrome.
I found that regex is to blame:
attrRegExp = /([\w:\-]+)(?:\s*=\s*(?:(?:\"((?:[^\"])*)\")|(?:\'((?:[^\'])*)\')|([^>\s]+)))?/g;
which I modified by replacing
((?:[^\"])*)
with
([^\"]*)
and
((?:[^\'])*)
with
([^\']*)
the resulting regular expression works in both browsers for my test case
attrRegExp = /([\w:\-]+)(?:\s*=\s*(?:(?:\"([^\"]*)\")|(?:\'([^\']*)\')|([^>\s]+)))?/g
can anyone highlight this?
my test data, which only work with the modified regular expression, is a large image> 700 kb, for example:
var testdata = '<img alt="" src="data:image/jpeg;base64,/9j/4AAQSkZJRgA...5PmDk4FOGOHy6S3JW120W1uCJ5M0PBa54edOFAc8ePX/2Q==">'
do something like this for testing:
testdata.match(attrRegExp);
especially when the test data is large, the unmodified regular expression most likely fails in firefox.
You can find the jsfiddle example here :
source share