When I released XRegExp 0.2 several days ago, I hadn't yet tested in Safari or Swift. When I remembered to do this shortly afterwards, I found that both of those WebKit-based browsers didn't like it and often crashed when trying to use it! This was obviously a Very Bad Thing, but due to major time availability issues I wasn't able to get around to in-depth bug-shooting and testing until tonight.
It turns out that Safari's regex engine contains a bug which causes an error to be thrown when compiling a regex containing a character class ending with "[\\
".
// These throw an error: [ /[[\\]/ , /[^[\\]/ , /[abc[\\]/ ] // ...While these are all fine: [ /[\\[]/ , /[\[\\]/ , /[[]/ , /[\\]/ , /[[\\abc]/ , /[[\/]/ , /[[(\\]/ ] // Testing: try { RegExp("[[\\]"); alert("OK!"); } catch (err) { alert(err); /* Safari shows: "SyntaxError: Invalid regular expression: missing terminating ] for character class" */ }
As a result, I've changed two instances of [^[\\]
to [^\\[]
and upped the version number to 0.2.2. XRegExp has now been tested and works without any known issues in all of the following browsers:
- Internet Explorer 5.5 – 7
- Firefox 2.0.0.4
- Opera 9.21
- Safari 3.0.2 beta for Windows
- Swift 0.2
You can get the newest version here.
Hi.
I have now published my SweetXML parser, using your XRegExp.
I developed it first without using your code, and you will be pleased to here that it was a 5 minute swap-in. Worked a dream, with no errors.
Julian
Sweet!
SweetButty seems like the perfect kind of project to use XRegExp… a regex intensive app, which becomes much more self-documenting though named capture.
http://bugs.webkit.org/show_bug.cgi?id=14823