Regex syntax error?
tizmagik opened this issue · comments
I boiled it down to this.
const r = /foo\/bar>/
A clue for a fix is that escaping fixes it...
const r = /foo\\/bar>/
I'm guessing that since we escape the source-text, this is an escaping case I'm not accounting for. Shouldn't be too hard to fix.
Thanks for bringing up the issue by the way! I pushed a fix to master, and will include it in the next build. The following script should work now. Let me know if there are any other issues with this, feel free to reopen if needed. :)
const extractSrc = scriptStr => {
const SCRIPT_SRC_REGEX = /<script.*src="(.*)"><\/script>/gi;
const [, url] = SCRIPT_SRC_REGEX.exec(scriptStr);
return url;
};
console.log(extractSrc(`<script src="x"></script>`))
Great work! Thanks 🙏