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 return false if one condition is false

I am new with regex and I wrote something what returns a match also if one part is correct.

This is incorrect, but the expression is returns true

This is correct return true

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

^(((https?:\/\/[w]{3}[.]{1})+([a-z0-9]{1,})(.*-[a-z]{1,})?)[.]{1}[a-z]{2,3}\/[a-z]{1,}(.*-[a-z]{1,})?)

*Important if the url contains – there must be a letter after if there is no letter after the expression is incorrect and return false *

>Solution :

You forgot the dollar sign!

Try this

/^((https?:\/\/[w]{3}[.]{1})+([a-z0-9]{1,})(.*-[a-z]{1,})?)[.]{1}[a-z]{2,3}(\/[a-z0-9]{1,})?(.*-[a-z]{1,})?$/
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