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:
- http://someurl.com
- https://someurl.com
- ${protocol}://someurl.com
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');
RegExpyou have to write all backslashes twice:(\\$\\{protocoletc.