• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 172
  • Last Modified:

Swapping link and text around.

I have multiple lines like this:<a HREF="http://www.test.com/cgi-bin/test.pl/one" target="new">
FRI Mar 3, 00, 11:47 AM</A>
Message one two three four text goes here test1<BR>
<a HREF="http://www.test.com/cgi-bin/test.pl/two" target="new">
FRI Mar 2, 00, 09:10 AM</A>
Message two three four text goes here test2<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?

So Output would be like this:

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

Maybe something like this:

$news =~ s!(<.+> )(.+)(</a> )(.+)<br>!$1$4$3$2!i;

I cant this to get work? What is the problem?

Hank

0
hoster19
Asked:
hoster19
  • 2
1 Solution
 
sanekCommented:
This will do a job:

$news = <<END_NEWS;
<a HREF="http://www.test.com/cgi-bin/test.pl/one" target="new">
FRI Mar 3, 00, 11:47 AM</A>
Message one two three four text goes here test1<BR>
<a HREF="http://www.test.com/cgi-bin/test.pl/two" target="new">
FRI Mar 2, 00, 09:10 AM</A>
Message two three four text goes here test2<BR>
END_NEWS

$news =~ s!<([^>]*?)>([^>]*?)</A>([^>]*?)<BR>!<$1>$3</A>$2<BR>!gi;

print $news;


0
 
sanekCommented:
I mean,
$news =~ s!<([^>]*?)>([^>]*?)</A>([^>]*?)<BR>!<$1>$3</A>$2<BR>!gi;
is what your search :)
0
 
hoster19Author Commented:
Thank You!

Check

http://www.modernmenus.com

escpesially the reverse auction!, You could earn some money there by answering questions.

Hank
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now