homepage Welcome to WebmasterWorld Guest from 54.166.14.218
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
Replacing URLs with Links
Davo1977

5+ Year Member



 
Msg#: 3717453 posted 10:54 am on Aug 7, 2008 (gmt 0)

Does anyone have a regex for giving a string for a link to a URL.
I need to write a link within my website to another website.

i think i need to use the s/// replacement operator.

 

perl_diver

5+ Year Member



 
Msg#: 3717453 posted 5:43 pm on Aug 7, 2008 (gmt 0)

give an example of the input data and desired output data, your question is not very clear.

rocknbil

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3717453 posted 1:23 am on Aug 8, 2008 (gmt 0)

Well not regex, but . . . run it on a command line, extract whatcha need.


#!/usr/bin/perl
until ($input =~ /^q/i) {
print "Type a full URL to test, q to quit:\n";
chomp($input = <STDIN>);
if ($input =~ /^q/i) { last; }
unless ($input =~ /^http/i) { $input = 'http://' . $input; }
$title = $input;
$title =~ s/https*:\/\/(www\.)*//i;
$link = qq<a href="$input">$title</a>;
print "Link code is $link\n";
}
print "exiting program\n";

[edited by: phranque at 5:29 am (utc) on Aug. 8, 2008]
[edit reason] disabled smileys ;) [/edit]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved