Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Regex that contains but doesn't start with

I need some help creating a regular expression to locate a bunch of instances of code that need to be refactored. The thing is there are hundreds of places that have already been updated and the code is similar so I’m struggling to come up with a regex that finds only the ones that I need to update.

I’m basically looking to change all instances of:

confirm(...

to

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

w360.confirm(...

So I need a regex that will locate all instances of the first while not including the instances of the second.

>Solution :

You can easily do it with a negative look-behind:

(?<!\.)confirm\(
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading