Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Swapping link and text around.

Posted on 2000-03-06
3
Medium Priority
?
171 Views
Last Modified: 2013-12-25
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
Comment
Question by:hoster19
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Expert Comment

by:sanek
ID: 2588426
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
 
LVL 2

Accepted Solution

by:
sanek earned 2000 total points
ID: 2588430
I mean,
$news =~ s!<([^>]*?)>([^>]*?)</A>([^>]*?)<BR>!<$1>$3</A>$2<BR>!gi;
is what your search :)
0
 

Author Comment

by:hoster19
ID: 2588592
Thank You!

Check

http://www.modernmenus.com

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

Hank
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn how to count occurrences of each item in an array.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question