Regex, what has been replaced?

DuskDweller
DuskDweller used Ask the Experts™
on
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)
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Freelance programmer / Consultant
Commented:
If you have the original - yes, you can compare before and after.
If you don't the best you can hope for is to identify locations where something might have been replaced.
AndyAinscowFreelance programmer / Consultant

Commented:
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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial