Solved

<a href

Posted on 2002-07-15
6
257 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
Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

 
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

Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

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…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
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…

624 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