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
Solved

Swapping link and text around.

Posted on 2000-03-06
3
166 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
  • 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 500 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
exchange, scripts 3 73
Installing Git and chefdk via bat script 8 86
copy-item script help 15 80
Awk To add just one column - modifying script from an answer 2 22
In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses. I wi…
In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

839 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