Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Regular Expression Problem

Reply
Thread Tools

Regular Expression Problem

 
 
KiwiBrian
Guest
Posts: n/a
 
      01-01-2005
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
 
 
 
 
Phoenix
Guest
Posts: n/a
 
      01-01-2005
KiwiBrian wrote:
> 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
 
 
 
 
mbstevens
Guest
Posts: n/a
 
      01-01-2005
KiwiBrian wrote:

> 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
 
mbstevens
Guest
Posts: n/a
 
      01-02-2005
mbstevens wrote:

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

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seek xpath expression where an attribute name is a regular expression GIMME XML 3 12-29-2008 03:11 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C++ 42 11-04-2008 12:39 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C Programming 45 11-04-2008 12:39 PM
Matching abitrary expression in a regular expression =?iso-8859-1?B?bW9vcJk=?= Java 8 12-02-2005 12:51 AM
Dynamically changing the regular expression of Regular Expression validator VSK ASP .Net 2 08-24-2003 02:47 PM



Advertisments