【发布时间】:2014-02-04 21:18:26
【问题描述】:
function fuzzQuery(rawQuery)
{
re = /(?=[\(\) ])|(?<=[\(\) ])/;
strSplit = rawQuery.split(re);
alert(strSplit);
};
不起作用(没有对话框)。
我检查了http://rubular.com/ 的表达式,它按预期工作。
而
re = /e/
确实有效。
输入字符串是
hello:(world one two three)
预期结果是:
hello:,(,world, ,one, ,two, ,three, )
我查看了以下 SO 问题:
Javascript simple regexp doesn't work
Why this javascript regex doesn't work?
但我不会犯错误,比如将表达式创建为字符串,或者当它是字符串时不使用双反斜杠。
【问题讨论】:
-
javascript 正则表达式不支持lookbehind..也许这里有一个替代方案..stackoverflow.com/questions/7376238/…
标签: javascript regex regex-lookarounds