+ Post New Thread
Results 1 to 4 of 4
*nix Thread, Regex Expression text only containing URL in Technical; I'm after a regex expression to determine if a item of text contains only a URL and nothing else (Spam ...
  1. #1

    Join Date
    Mar 2013
    Location
    west sussex
    Posts
    519
    Thank Post
    74
    Thanked 26 Times in 26 Posts
    Rep Power
    15

    Regex Expression text only containing URL

    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.

  2. #2

    Join Date
    Mar 2013
    Location
    west sussex
    Posts
    519
    Thank Post
    74
    Thanked 26 Times in 26 Posts
    Rep Power
    15
    okay so i've answered my own question,

    Regular Expression Library

  3. #3

    sonofsanta's Avatar
    Join Date
    Dec 2009
    Location
    Lincolnshire, UK
    Posts
    4,990
    Thank Post
    865
    Thanked 1,451 Times in 998 Posts
    Blog Entries
    47
    Rep Power
    618
    You may like: Regex Tester. Has been a godsend for me.

  4. #4


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    9,006
    Thank Post
    230
    Thanked 2,693 Times in 1,988 Posts
    Rep Power
    791
    Here's another good regex since it also matches short URLs such as goo.gl, bit.ly and t.co.

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

    Last edited by Arthur; 11th June 2013 at 10:01 PM.

SHARE:
+ Post New Thread

Similar Threads

  1. [OPEN] Bug/Error: Editing a post after an embedded URL forces all new to text to be underlined
    By Dos_Box in forum EduGeek.net Site Problems
    Replies: 0
    Last Post: 26th October 2011, 09:21 AM
  2. Replies: 1
    Last Post: 22nd September 2011, 04:08 PM
  3. Block URLs containing IP addresses.
    By sjatkn in forum How do you do....it?
    Replies: 12
    Last Post: 8th October 2009, 12:43 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •