I have several functions across different files, and they usually are like this:
"prefix":"functionName (...)"
, like pub:isInt
. And I wanted to put the first letter of the function as capital, so I did this regex to change to pub:IsInt
(this also rejects other non-intented matches, that is why it is like this):
MATCH: ([a-z]+):([a-z])([a-z t_:]*)?(?=()
REPLACE: $1:U$2$3
This works fine for one function, the problem is when I have several functions in the same line, like:
pv:collect(table | pv:hasElement(table) AND pv:element(table))
Search and Replace in multiple files does this:
pv:Collect(table | pv:Collect(table) AND pv:Collect(table))
which is wrong because $1
, $2
and $3
match only the first for the whole line.
Search and Replace in one file does the correct:
pv:Collect(table | pv:HasElement(table) AND pv:Element(table))
Does anyone happen to know what the error might be?
2
Answers
This looks like an actual bug in VSCode
I’ve created an issue: https://github.com/microsoft/vscode/issues/196592
Your regex will match more than you think, see regex101 demo.
VS Code will produce 2 matches as well IF you enable the
MatchCase
option – otherwise it’ll treat your[a-z]
as[a-zA-Z]
.Perhaps you can use
^
at the beginning of the regex like:You see I added
A-Z
so you don’t need theMatchCase
option.I think what you really want is
I added
|()
to your character class. And I usedw
so it handles both lower and upper characters. See regex101 demo and tested in vscode.