LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] regexps for domains

[ILUG] regexps for domains

Kevin O'Riordan kor at compsoc.com
Thu Aug 11 15:45:24 IST 2005


Hi,

> new one:
> /(ftp:\/\/|http:\/\/|https:\/\/|www|[a-zA-Z0-9-]+\.|[a-zA-Z0-9\.-]+@)(([a-zA-Z0-9-][a-zA-Z0-9-]+\.)+[a-zA-Z]+[a-zA-Z0-9-,\.\/\_\?\%\#\&\=\;\~\!\(\)]+)/
>
> the old one was also vulnerable to stupid domains like -.-.- - the new 
> one is still not perfect, but ...

You could have a separate regexp that matches valid time ranges,
something like:

    /\b[0-9]{2}:[0-9]{2}-[0-9]{2}:[0-9]{2}\b/	# perlish \b

and then only match your domain regexp on the condition that the time
range didn't match, something like so:

    if ( TIME_RANGE_REGEXP_HERE )
        # Whatever it is you normally (don't) do.
    else if ( DOMAIN_NAME_REGEXP_HERE )
        highlight

This being a kinda obvious solution, I'm wondering if it's already been
shot down?  If so, why?  Not criticising, just curious as to people's
approaches to these things.  I know if I read the increasingly clever
domain regexp I wouldn't notice that it skips numeric domain names /
time ranges, so I'd prefer to see the time range regexp case matched
explicitly.

-Kev



More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell