Will all browsers (IE6+, FF3+, Safari 3+, Chrome) execute a javascript regex search across line boundaries in the searched string? Example:
var sourceStr = "This is some text \nOn multiple lines\nAnd the 2nd line.";
sourceStr = sourceStr.replace(/line/g, "xxx");
Also, are there any good references of what regex features are or aren't supported in various browsers.
Yes, but if you use any char syntax - dot "." in regex patterns, you may need to change it to [\s\S]
to match any chars across lines.
The ECMA specification ( ECMA-262 ) dictates acceptable regular expression grammar and multiline support is explicitly mentioned. Section 15.10.2.6 in particular demonstrates the effect of multiline support on Assertions.
So, if the browser supports the ECMA-262 specification, then yes, it supports multiline.
Of course, you should endeavor to test your code before you can be confident it works. It wouldn't be the first time a browser has failed to implement a specification correctly.
EDIT: To clarify, JavaScript 1.5 is fully compatible with ECMA-262, Edition 3. I understand the following browsers support JavaScript version 1.5 or higher:
Can't actually find a decent source for Chrome although I'd be shocked if it didn't support JavaScript >= 1.5.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.