简体   繁体   中英

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.replace( /(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 (?<=) ."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM