I am trying to match a URL using the following regex, in Java
^http(s*):\\/\\/.+:[1-65535]/v2/.+/component/.+$
Test fails using URL: https://box:1234/v2/something/component/a/b
I suspect it’s the number range that’s causing it. Help me understand what am i missing here please?
See http://www.regular-expressions.info/numericranges.html. You can’t just write
[1-65535]to match1or65535. That says any number1-6, or5or3.The expression you need is quite verbose, in this case:
(Credit to http://utilitymill.com/utility/Regex_For_Range)
Another issue is your
http(s*). That needs to behttps?because in its current form it might allowhttpsssssssss://. If your regex takes public input, this is a concern.