How find and replace a string in the HTML file


J

jussi

hi gurus

I need to replace some string in the html file but haven't manage to
work it out.

In a HTML file I have a string :

......<a href="javascript:CreateList(TopForm)"><img
src="images/playselected.gif" bgcolor="#949494" align="right/"
border="0"></a>
....


Which I need to replace with this one:

&nbsp;


I have look for exsample HTML::parser but couldn't understand how it
works !!

So please, give me exsample code how to find a string and replace it.

Thanks advance
-Jussi
 
Ad

Advertisements

J

Julia De Silva

hi gurus
I need to replace some string in the html file but haven't manage to
work it out.

In a HTML file I have a string :

.....<a href="javascript:CreateList(TopForm)"><img
src="images/playselected.gif" bgcolor="#949494" align="right/"
border="0"></a>
....
Which I need to replace with this one:

&nbsp;

I'm CERTAINLY NOT a guru but

my $str = "Mary had a large lamb";

$str = s/large/little/g;

might get you started

J
 
J

Julia De Silva

Sorry That's
my $str = "Mary had a large lamb";
$str =~ s/large/little/g;

J
 
G

Gunnar Hjalmarsson

jussi said:
I need to replace some string in the html file but haven't manage to
work it out.

In a HTML file I have a string :

.....<a href="javascript:CreateList(TopForm)"><img
src="images/playselected.gif" bgcolor="#949494" align="right/"
border="0"></a>
....

Which I need to replace with this one:

&nbsp;

I have look for exsample HTML::parser but couldn't understand how it
works !!

If you search this group, you'll find examples of how to use it.

If the above is the only thing you want to replace, something like this
may be sufficient:

$html =~ s#<a\s+href.+?CreateList\(TopForm\).+?</a>#&nbsp;#is;
 
J

jussi

Thanks Gunnar, it work fine !

But when I use the same method to find and replace next string:

<a
href="javascript:popUpPlayFile('./PlayFile.asp?E:\\video\\[email protected][email protected]%CH20so-',1)">


With this:
<a ref file://LINK_TO_VIDEO >

And I do it like this

$html =~
s#<a\s+href"javascript:popUpPlayFile.+?506-TEST-VIDEO.+?>img<#<a ref
file://LINK_TO_VIDEO >#is;

This doesn't work. Any help would be nice ..

-Jussi
 
Ad

Advertisements

G

Gunnar Hjalmarsson

jussi said:
Thanks Gunnar, it work fine !

What works fine? Please provide context when replying to a message, as
is recommended in the posting guidelines for this group:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
(Those who may be able to reply don't usually access the group via Google.)
But when I use the same method to find and replace next string:

<a
href="javascript:popUpPlayFile('./PlayFile.asp?E:\\video\\[email protected][email protected]%CH20so-',1)">

With this:
<a ref file://LINK_TO_VIDEO >

Do you possibly mean

And I do it like this

$html =~
s#<a\s+href"javascript:popUpPlayFile.+?506-TEST-VIDEO.+?>img<#<a ref
-------------^---------------------------------------------^^^^

Where is the equality sign?

What's 'img<'?
file://LINK_TO_VIDEO >#is;

This doesn't work. Any help would be nice ..

You can help both yourself and us by checking your code _carefully_
before asking hundreds of people for help.
 
Ad

Advertisements


Top