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 for finding URL match if nothing and after the URL but ignore if found in multiline

Guys I need to create a regex of a URL https://www.test.com/88f19 (last 5 digits can change) and I came up with https:\/\/www.test.com\/[a-fA-F0-9]{5} and it works fine. But the problem is that I only need to match this URL if and only if nothing exists before and after this URL. e.g. this should match https://regex101.com/r/LdfVFW/1 whereas this should not match since there is some other text in multi line with the URL https://regex101.com/r/namAOd/1. Would appreciate some inputs!

>Solution :

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

Use \A (start of all input) and \Z (end of all input) at either end:

\Ahttps:\/\/www.test.com\/[a-fA-F0-9]{5}\Z

See live demos:

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