是否所有浏览器都使用正则表达式来处理多行搜索? [英] Do all browsers handle searching multi-line with regex?
本文介绍了是否所有浏览器都使用正则表达式来处理多行搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所有浏览器(IE6 +,FF3 +,Safari 3 +,Chrome)是否会跨搜索字符串中的行边界执行javascript正则表达式搜索?示例:
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.
推荐答案
是的,但是如果你使用任何字符语法 - 点。在正则表达式模式中,您可能需要将其更改为 [\\\ S]
以匹配跨行的任何字符。
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.
这篇关于是否所有浏览器都使用正则表达式来处理多行搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文