0

I am having some difficulty getting my regular expressions to pass. My expression is supposed to validate a url. For the protocol, it will allow three values: http, https, and ${protocol}.

So, here are some examples of VALID urls:

So far, the first two pass with my current RegExp, but the ${protocol} ones won't pass. Can some one please try to help me debug this and see why my ${protocol} isn't passing?

Here is my RegExp so far:

var urlRegEx = new RegExp('(\$\{protocol\}|http(s)?)://(([A-Za-z0-9-]+\.)*([A-Za-z0-9-]+\.[A-Za-z0-9]+))+((/?)(([A-Za-z0-9\._\-]+)(/){0,1}[A-Za-z0-9.-/]*)){0,1}', 'i');
2
  • 3
    when using RegExp you have to write all backslashes twice: (\\$\\{protocol etc. Commented Nov 11, 2013 at 9:14
  • @thg435 Make that an answer? Commented Nov 11, 2013 at 9:34

1 Answer 1

1

when using RegExp you have to write all backslashes twice: (\\$\\{protocol etc.

(from thg435's comment)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.