Regular Expression Problem

K

KiwiBrian

Using any Search and Replace program what would I enter to remove the
following string from many files which are all in the same folder:-

<!-- 108p3.htm 08:05 GMT -->

The text is different in every instance, but the opening and closing comment
bits are the same.
TIA
Brian Tozer
 
P

Phoenix

KiwiBrian said:
Using any Search and Replace program what would I enter to remove the
following string from many files which are all in the same folder:-

<!-- 108p3.htm 08:05 GMT -->

The text is different in every instance, but the opening and closing comment
bits are the same.
TIA
Brian Tozer

If it supports regular expressions, you can select that by doing "<!--
[^-]+-->", or so I believe, at least. You may have to escape something
in there, though I wouldn't think so.
 
M

mbstevens

KiwiBrian said:
Using any Search and Replace program what would I enter to remove the
following string from many files which are all in the same folder:-

<!-- 108p3.htm 08:05 GMT -->

The text is different in every instance, but the opening and closing
comment bits are the same.
TIA
Brian Tozer

Then you can play with something vaguely like:

find2perl . -type f -name "*.html" -print |\
perl -pi.BAK -e "s/<!--.+-->//g;";

....but if you bring down the internet and the governments of several
third-world countries with it, along with your hard disk and your marriage,
don't come crying to me.
 
M

mbstevens

Then you can play with something vaguely like:

find2perl . -type f -name "*.html" -print |\
perl -pi.BAK -e "s/<!--.+-->//g;";

Well, since they're all in the same folder, this simpler one might work
better:
perl -pi.bak -e "s/<\!--.+-->//g;" *.html

....but would likely fail if the commented text spans several lines.
 

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

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top