I'm creating a reg exp for validating only those URLs from the list where parameter p has a value between 100 and 9999. So from the list given below, only 3rd and 4th URL need to return true as output when they are entered into a textbox.
http://www.website.com/our-resources/news/?p=1
http://www.website.com/example/voice-of-the-customer/news/?p=12
http://www.website.com/our-resources/news/?p=123
http://www.website.com/example/?p=4321
http://www.website.com/example/products/touchchat/news/?p=12345
HTML
<input type=url/>
<button>Validate</button>
<div id=status></div>
Javascript
$('button').click(function(){
var val = $('input').val();
var regex = /^(https?:\/\/)?[a-z0-9-]*\.?[a-z0-9-]+\.[a-z0-9-]+(\/[^<>]*)?$/;
var isValid = regex.test(val);
$('#status').text(isValid);
});
But this regex returns true for all URLs. What changes should I make to this expression?