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

Support Regex that has more than one forward slash in domain

I need to support endpoints such as

/myendpoint:
/v1/myendpoint:
/v3/someotherendpoint:

This regex:

const regexPattern = '/[a-zA-Z0-9-]+:';

Only answers to /myendpoint:

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

How can we do an or operation to support both cases ?

>Solution :

Just make it something like recursive your existing solution for its multiple instance.

Example: (\/[a-zA-Z0-9-]+)*:

Play: https://regexr.com/6jka3

The character * in a regular expression means "match the preceding character zero or many times"

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