Solved

<a href

Posted on 2002-07-15
6
255 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
[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
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
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

729 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