Solved

Swapping link and text around.

Posted on 2000-03-06
3
169 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…

728 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