Solved

<a href

Posted on 2002-07-15
6
251 Views
Last Modified: 2013-12-25
I've got a html file which contains lines with <a href="blablabla">interesting text</a>

How can I open this html file and delete all occurences of <a href="bliblibli"> and </a>

"blablabla and bliblibli are just examples, it are random words.
0
Comment
Question by:oostwijk
6 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 7156391
perl -i.bak -pe "s#</?a\b[^>]*># #gi;" file
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7156804
still hac been answered in http://www.experts-exchange.com/perl/Q_20323316.html
Ask support at EE to delete this question.
0
 

Author Comment

by:oostwijk
ID: 7158112
i posted this question before in the perl section, but it was ment to be a cgi question.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 5

Accepted Solution

by:
Peewee earned 50 total points
ID: 7159085
oostwijk,

if you need to do this within your code a good way to do this as follows:

#!/usr/bin/perl
#
#####################################
# Code by Peewee              #
#                        #
#####################################
#

use CGI;
use CGI::Carp qw(fatalsToBrowser);
use strict;

my $doc                    =     shift;
my $html_page;

### main processing is encapsulated here

open (PAGE, "<$doc") || die "unable to open $doc";  
while (<PAGE>) {

     $html_page     .= $_;
}
close PAGE;

$html_page     =~ s/<a href=".*">.*<\/a>/link/ig;


print qq~
$html_page
~;


Note that that to print this to the browser you will need a print "Content-type: text\html \n\n";

regards Peewee
0
 
LVL 5

Expert Comment

by:Peewee
ID: 7164432
oostwijk,
did you get the sloution u were looking for?

regards Peewee
0
 

Author Comment

by:oostwijk
ID: 7168649
sorry, for my late responce... This works fine.
Thanks m8
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reading variable length EBCDIC in SAS 9 98
Ready Made PHP Scripts 5 63
Python 2.7 - Passing arguments 8 59
pass a variable from a list to a batch file using psexec 11 47
Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

863 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

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now