Link to home
Avatar of DuskDweller
DuskDwellerFlag for Italy

asked on

Regex, what has been replaced?

Plain and simple: Is there a way to know what my regex pattern has replaced? (my regex is just replacing the first occurrence of a given pattern in a long scripting language file)
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
I say might because.
Consider 'xyz foo bar abc' and you replace the first instance of abc with xyz so you then have 'xyz foo bar xyz'.  Now you don't know which of the following was the original:
xyz foo bar abc
abc foo bar xyz
xyz foo bar xyz
Do you not use a version control system?? you can always check for previous checkins and any possible changes that've been made through that.