Im using JREPL.BAT to find and replace specific instances and my regex I have works for find and replace in VSC code and also in the couple regex editors I've used.
CALL ./framework/config/JREPL.BAT "(Error)+\(([^()]*|\(([^()]*|\([^()]*\))*\))*\)" "Error(\"\")" /f ./dist/index.html /o
so what I'm expecting is it to find any case of
Error("")
or
Error( skjdksjdskd() + "" + )
etc
Find and replace works perfectly but jrepl takes
Error( skjdksjdskd() + "" + )
and changes it to
Error()( skjdksjdskd() + "" + )
does anyone know with more JREPL experience know why its ignoring the quotes and also not replacing the () area?
JREPL is hybrid JScript/batch that uses CSCRIPT - the Windows script host.
CSCRIPT has an inherent limitation that prevents double quote literals from being passed as parameters - there is no CSCRIPT escape sequence that includes a
"literal.To include a
"literal in your query string, you can use\x22instead. All of the standard JScript escape sequences can be used in the query string. By default, escape sequences are not recognized in the replace string.But you want a quote literal in your replace string. This requires the
/XSEQoption so you can use the JREPL extended escape sequence of\q. A significant advantage of this option is you can also use the extended escape sequences in the replace string. You could also use\x22for both the search and replace strings if you prefer, but I find\qmuch easier to remember.You have one other potential problem - the CALL command doubles all quoted carets, so
[^()](any character other than(or)) becomes[^^()](any character other than^,(or)). This is definitely not what you want. That is the reason I added the\c=^extended escape sequence.So I believe the following will give your expected result:
FYI - The effect of the
^beginning of string anchor is not harmed by caret doubling - you don't need the\cescape sequence for the beginning of string anchor because"^MatchStringBeginning"and"^^MatchStringBeginning"yield identical regex results.You can get more information about the extended escape sequences by issuing
jrepl /?/xseq, orjrepl /??/xseqfor paged help.Final Answer for this is to escape the quotes and backslashes as
\"AND\\when using CALL in Webpack-shell-plugin.