Jump to content

Recommended Posts

Posted

I'm after a regex expression to determine if a item of text contains only a URL and nothing else (Spam rule)

 

I'm thinking this should be possible and am reading about it at the moment, if anyone already knows what it is please post it.!

 

My regex is a little rusty, so I've a little catching up to do.

Posted (edited)

Here's another good regex since it also matches short URLs such as goo.gl, bit.ly and t.co.

 

(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))

 

Source: Daring Fireball

 

http://i.imgur.com/55kLKcN.png

Edited by Arthur

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...