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? Link to comment https://forums.phpfreaks.com/topic/48856-how-far-off-am-i-o/ 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 Link to comment https://forums.phpfreaks.com/topic/48856-how-far-off-am-i-o/#findComment-239577 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 Link to comment https://forums.phpfreaks.com/topic/48856-how-far-off-am-i-o/#findComment-239588 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.