Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

<a href

Posted on 2002-07-15
6
Medium Priority
?
264 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 85

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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
LVL 5

Accepted Solution

by:
Peewee earned 200 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
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…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

972 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