I did this in FIND field:
Info\((.*?), "Ne
But when i replace it with this:
Error\((.*?), "Ne
I get this:
Error((.*?), "Ne
example this is Info without regex:
Info(playerid, "Ne
I want to ignore playerid with regex and replace it with
Error(playerid, "Ne
or
Info(id, "Ne
with
Error(id, "Ne
Sorry I’m newbie with Regular Ex…
Thank you all!
RegEx Find & Replace
If you break down your regular expression of Info\((.*?), "Ne
, you get this:
- Match the literal text
Info(
- Match any number of characters, but as few of them as possible and capture them for later
- Match the literal text
, "Ne
Presumably that’s matching what you want it to match based on your description, so you’re good there.
Where you’ve gone astray is in the replacement text. As you’ve noticed, if you use (.*?)
in the replacement text, that’s what comes out in the replacement; i.e. you’ve literally said to use that as the replacement text.
Fortunately, in #2 above the part of the regex that matches the part you want to keep appears between (
and )
characters, which tells the regex that whatever it finds there, it should capture.
All of the captures in a regular expression are numbered starting with 1 and are available to the replacement text using the syntax $n
or \n
, which will get replaced with whatever the captured text was (if anything).
So your replacement text should be Error(\1, "Ne
or Error($1, "Ne
to do what you want.