Gossamer Forum
Home : General : Perl Programming :

Swapping link and text?

Quote Reply
Swapping link and text?
<a HREF="http://www.test.com/cgi-bin/test.pl" target="new">
FRI Mar 3, 00, 11:47 AM</A>
Message one two three four text goes here<BR>

What kind of statement or expression I need to build, if I want to swap Time and Message other way around: Message first and then time. And also I want message to be the link, and time just text?

$swap =~ s/{notsure1}{something likethis}/sig;

I have no Idea Smile

------------------
Hank Osterlund
hank@modernmenus.com
www.modernmenus.com
Answers for your tough questions.


[This message has been edited by Hank (edited March 05, 2000).]
Quote Reply
Re: Swapping link and text? In reply to
Not sure I understand what you are talking about. Is this what you mean?

$text = '<a HREF="http://www.test.com/cgi-bin/test.pl" target="new">FRI Mar 3, 00, 11:47 AM</A>Message one two three four text goes here<BR>';
$text =~ s!(<.+> )(.+)(</a> )(.+)<br>!$1$4$3$2!i;
print $text;

(make sure to remove the spaces in the substitution)

output is:
<a HREF="http://www.test.com/cgi-bin/test.pl" target="new">Message one two three four text goes here</A>FRI Mar 3, 00, 11:47 AM

--mark

[This message has been edited by Mark Badolato (edited March 05, 2000).]
Quote Reply
Re: Swapping link and text? In reply to
Looking good, Output exactly like I want, but....
$text =~ s!(<.+> )(.+)(</a> )(.+)<br>!$1$4$3$2!i;
Is <br> supposed to be inside parentheses () also?

I cant express it like:$text = '<a HREF="http://www.test.com/cgi-bin/test.pl" target="new">FRI Mar 3, 00, 11:47 AM</A>Message one two three four text goes here<BR>';
because time is dynamic, and it changes constantly.
It would have to be like:
$news =~ s/\SRC\=\"\/images/SRC\=\"http\:\/\/www.modernmenus.com\/images/sig;
(I know this will swap, but not like I wanted)

Just learning and I think it is the correct format, I keep trying....