I have the form on my page with text url
field. User can input there any value, like:
- http://example.com/forum/viewtopic.php?t=557761&sid=daea20300c8eea4681fd1d87aa76c622
- http://www.example.com/forum/viewtopic.php?t=557761&sid=daea20300c8eea4681fd1d87aa76c622
- www.example.com/forum/viewtopic.php?t=557761&z=123456
- example.com/forum/viewtopic.php?t=557761&sid=daea20300c8eea4681fd1d87aa76c622
- 557761
How can I validate that correct domain is given (example.com
) and then extract topic id (557761
)?
Looks like I should use jQuery.isNumeric
first (to capture last case), if it is not numeric, then I can extract the value like /^.*t=(\d+)$/
. But how should I check the domain in the regex?