开发者

Problem with regular expression lookbehinds in javascript

I want to retrieve via regexp javascript figures

I thought of using lookbehind but it seems that javascript does not support lookbehind

thank you for helping me


Your description is slightly confusing. By "nothing" do you mean anything, a space, or the beginning/end of the text? I'm assuming a space.

Although look-behind would be useful, it's not strictly necessary. Couldn't you just match the whole pattern?

document.body.innerHTML.search(/(and|or)? 1/);
document.body.innerHTML.search(/2 (and|or)?/);


If you do really need lookbehind, this might get you started: http://blog.stevenlevithan.com/archives/mimic-lookbehind-javascript (and there's tons of other great stuff on there for Javascript regex, including his library, XRegExp).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜