Re: regex to match any url



nodiseos@xxxxxxxxx wrote in news:1139950940.817938.158230
@g14g2000cwa.googlegroups.com:

I am struggling way too much with this. Does someone have a regex
that
will match any url-ish string like. Not worried about mail links.

http://sd.org
www.dssd.com
ibm.mil
https://sdsdsd.jobs
xyz.travel

Please show what you have tried and what has not worked so that we can
help you with what you don't know rather than acting as a "write-my-
code-for-me" service.

#!/usr/bin/perl

use strict;
use warnings;

while ( <DATA> ) {
print if m{ \A (?: https?:// )? \w+ (?: \. \w+)+ \n \z }x;
}

__DATA__
http://sd.org
www.dssd.com
ibm.mil
https://sdsdsd.jobs
xyz.travel

D:\Home\asu1\UseNet\clpmisc> u
http://sd.org
www.dssd.com
ibm.mil
https://sdsdsd.jobs
xyz.travel



--
A. Sinan Unur <1usa@xxxxxxxxxxxxxxxxxxx>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

.



Relevant Pages

  • [OT] Re: Media Lending Library - web based application
    ... >> (reverse each component and remove .invalid for email address) ... >> comp.lang.perl.misc guidelines on the WWW: ... snip your gaudy signature ...
    (comp.lang.perl.misc)
  • Re: Perl script does not work
    ... lower precedence or rather than ||. ... (remove .invalid and reverse each component for email address) ... comp.lang.perl.misc guidelines on the WWW: ...
    (comp.lang.perl.misc)
  • Re: How do I handle an unknown number of keys to hash?
    ... might be to insert the key into the hash with some default value but ... (remove .invalid and reverse each component for email address) ... comp.lang.perl.misc guidelines on the WWW: ...
    (comp.lang.perl.misc)
  • Re: extract variables from expression
    ... Why do you lie to the web browser? ... (remove .invalid and reverse each component for email address) ... comp.lang.perl.misc guidelines on the WWW: ...
    (comp.lang.perl.misc)
  • Re: Prematch ($`) and the m//g modifier
    ... in order to preserve the begin and end markings. ... (reverse each component and remove .invalid for email address) ... comp.lang.perl.misc guidelines on the WWW: ...
    (comp.lang.perl.misc)