Closed not-lum closed 3 years ago
I think the error is clear Invalid lookaround, expected closing symbol. Beware lookaround is currently limited to match one single character
, and maybe that limitation will be lifted someday. That said, the code snippet doesn't seem to work the way you expect it in re
(PCRE) either...
btw, here are some regex that may work in your case:
# similar to yours
"[\"'][^\"']+[\"']"
# a probably better one, since it won't match "foo'
"\"[^\"]+\"|'[^']+'"
# using raw string, otherwise \w will need double escaping \\w
# triple quoting is needed because the string contains quotes
r"""["'][^"']+["']"""
# passing the regex as raw string to re
const reg = re"""["'][^"']+["']"""
echo "\"in quotes\"".replace(reg, "$1")
or
echo "\"in quotes\"".replace(re"""["'][^"']+["']""", "$1")
I'm working on full lookaround support, see #94
Code:
Expected output:
Current output:
Additional information: