我试图通过圆括号()中的javascript字符串值导出。
有效的示例:
var a = "(test) (a b c)";
alert(a.match(/\([\s\S]+?\)/gi));//output: [(test),(a b c)]但在一些较旧的浏览器中"?“造成错误。
所以我做了这个:
var a = "(test) (a b c)";
alert(a.match(/\([A-Za-z0-9\-_\t\r\n\s]+\)/gi));但是,这种方式不支持外文字符。因此需要使用\S
我需要一个\s\S的解决方案,它不使用信号。
发布于 2012-10-12 03:21:01
您可以匹配非)字符:
/\([^)]+\)/发布于 2012-10-12 03:20:52
这个更容易些
"(test) (a b c)".match(/\([^\)]+\)/gi); // output: ["(test)", "(a b c)"]发布于 2012-10-12 03:21:45
你觉得这能帮到你,不是吗?
(^)*)
http://gskinner.com/RegExr/
https://stackoverflow.com/questions/12851680
复制相似问题