HighDots Forums  

Regular Expression Problem

alt.html alt.html


Discuss Regular Expression Problem in the alt.html forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
KiwiBrian
 
Posts: n/a

Default Regular Expression Problem - 01-01-2005 , 02:33 PM






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



Reply With Quote
  #2  
Old   
Phoenix
 
Posts: n/a

Default Re: Regular Expression Problem - 01-01-2005 , 04:17 PM






KiwiBrian wrote:
Quote:
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.


Reply With Quote
  #3  
Old   
mbstevens
 
Posts: n/a

Default Re: Regular Expression Problem - 01-01-2005 , 05:04 PM



KiwiBrian wrote:

Quote:
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.
--
mbstevens http://www.mbstevens.com



Reply With Quote
  #4  
Old   
mbstevens
 
Posts: n/a

Default Re: Regular Expression Problem - 01-01-2005 , 11:48 PM



mbstevens wrote:

Quote:
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 --

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.






Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.