Jump to content

How far off am I? ::o


jscix

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.