Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

Replacing URLs with Links

10:54 am on Aug 7, 2008 (gmt 0)

New User

5+ Year Member

joined:June 25, 2008
posts: 24
votes: 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.

5:43 pm on Aug 7, 2008 (gmt 0)

Preferred Member

10+ Year Member

joined:Jan 5, 2006
votes: 0

give an example of the input data and desired output data, your question is not very clear.
1:23 am on Aug 8, 2008 (gmt 0)

Senior Member

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

joined:Nov 28, 2004
votes: 0

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

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]


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members