I looked at this question:
What is a good regular expression to match a URL?
And took the most up-voted answer which is this regex:
^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$
This works great to validate urls, HOWEVER, I also need this to allow strings such as this:
http://www.cool.com:81/index.html?query=${query}&sortBy=${sortBy}
Notice the placeholder strings such as ${query}
and ${sortBy}
(there can be any letters a-z inside the brackets). These are later replaced with actual values so the final url would look like this:
http://www.cool.com:81/index.html?query=helloworld&sortBy=population
I've been playing around with the regex to see if I can add a condition where those placeholders are allowed but none of my attempts have been successful unfortunately.
How can I do this?
EDIT:
The duplicate question provided does not answer how to match ${query}
but rather specific urls that just has parameters.