jscix Posted April 26, 2007 Share Posted April 26, 2007 Okay, I just read a basic page on regex. I'm trying to come up with a regex expression for validating an url. /^http://[.*]\.[a-zA-Z0-9]\.[.{2}]|[.{3}]\/[.*]$/ ^ I think this says: Starting with http:// Followed by any amount of any character .* Followed by a period \. Followed by any string (a-z A-Z and 0-9) Followed by a period \. Followed by any two characters .{2} OR Followed by any three characters .{3} Followed by a / Ending with any amount of characters .*$ (Sorry in advance for the questions, I figure i'll never understand this stuff If I just keep borrowing other peoples regex) I'm just curious how close I was with that? Also im curious about a few things.. 1. When do you use brackets? And why? [ ] 2. When do you use Parentheses? And why? ( ) 3. What should my regex have looked like, for validating an url? Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted April 27, 2007 Share Posted April 27, 2007 google still works. http://www.urgentclick.com/scripts/url-validation.html Quote Link to comment Share on other sites More sharing options...
fert Posted April 27, 2007 Share Posted April 27, 2007 [] are used for a range like a-z () are used for subpatterns Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.