+ 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
    14

    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
    14
    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,829
    Thank Post
    840
    Thanked 1,399 Times in 962 Posts
    Blog Entries
    47
    Rep Power
    603
    You may like: Regex Tester. Has been a godsend for me.

  4. #4


    Join Date
    Feb 2007
    Location
    51.405546, -0.510212
    Posts
    8,709
    Thank Post
    220
    Thanked 2,615 Times in 1,926 Posts
    Rep Power
    777
    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
  •