开发者

Help needed with correct escaping of regular expression javascript

I just started working with RE in javascript. I created a the syntax in a prog called RegExr from gskinner.com and and it's work perfectly fine in it, with my test data, but in javascript in throws "invalid quantifier" error. From what I can understand it probably means ther is unescaped special chars. I've been searching the whole day with no success. I am posting my code as I had it in RegExr, as I think my attempts will only make thing more difficult. Please help me.

Code:

data = data.rep开发者_开发百科lace( /(Photo)|(?<=Photo:)(.+?)(?=Stock)|(Stock Code)|(?<=Stock Code:)(.+?)(?=Make:)|(Make)|(?<=Make:)(.+?)(?=Model:)|(Model)|(?<=Model:)(.+?)(?=Year:)|(Year)|(?<=Year:)(.+?)(?=Price:)|(Price)|(?<=Price:)(.+?)(?=Description:)|(Description)|(?<=Description:)(.+?)(?=Photo:)|(?<=Description:)(.+?)(?=$)/g, "");

Thanks in advance. Jacques


In the interest of closing this question, like @BoltClock correctly stated. "JavaScript does not support lookbehind assertions (?<=)."

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜