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
 
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\\506-TEST-VIDEO.mpg@$$@506-SRI%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
 
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\\506-TEST-VIDEO.mpg@$$@506-SRI%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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top