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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.