RegExp

They have: 5,633 posts

Joined: Jan 1970

I have never talked to anyone else who uses regual expressions when they write code but I'm going to ask any way....

I'm useing this RegExp...

temp_Reg = /www\x2E\w{1,}\x2E\w{3}/i;
'

I'm useing the match() method to get it to mach eather of the fallowing...

Quote: www.bja888.com
bja888.com

The only proublem is i dont know how to make it match www. or not www.
Any sugestions?

timjpriebe's picture

He has: 2,667 posts

Joined: Dec 2004

Is this a Perl RegEx or PHP?

I think PHP has slightly different syntax that Perl, which I'm used to using. That's why I'm asking.

They have: 5,633 posts

Joined: Jan 1970

Jscript.net but the idea is the same. I can look up the proper syntax, but i dont know the approach I should use.

timjpriebe's picture

He has: 2,667 posts

Joined: Dec 2004

Maybe something like this

/(www\.)*[^\.]+\.[^\.]{2,3}/

That will match something that starts with zero or more www. 's, followed by one or more non-period 's, then a period, then 2 or 3 non-periods.

I haven't tested it, but this should match both of yours, plus things that end with two-letter extensions as well.

They have: 5,633 posts

Joined: Jan 1970

Ph thank you, the thing I was missing is you can have it match 0 or more. I will just do 0 or more ws then 0 or 1 ".". Thank you.

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Are you only looking to match .com domains?

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.