Regular Expression Problem

Discussion in 'HTML' started by KiwiBrian, Jan 1, 2005.

  1. KiwiBrian

    KiwiBrian Guest

    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
    KiwiBrian, Jan 1, 2005
    #1
    1. Advertising

  2. KiwiBrian

    Phoenix Guest

    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.
    Phoenix, Jan 1, 2005
    #2
    1. Advertising

  3. KiwiBrian

    mbstevens Guest

    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
    mbstevens, Jan 1, 2005
    #3
  4. KiwiBrian

    mbstevens Guest

    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.
    mbstevens, Jan 2, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. godfather2

    Regular Expression problem

    godfather2, Jul 20, 2003, in forum: Perl
    Replies:
    1
    Views:
    993
    Shawn Corey
    Jul 20, 2003
  2. VSK
    Replies:
    2
    Views:
    2,269
  3. Nazir
    Replies:
    3
    Views:
    5,049
    jayendra gadhavi
    Jan 2, 2008
  4. =?iso-8859-1?B?bW9vcJk=?=

    Matching abitrary expression in a regular expression

    =?iso-8859-1?B?bW9vcJk=?=, Dec 1, 2005, in forum: Java
    Replies:
    8
    Views:
    831
    Alan Moore
    Dec 2, 2005
  5. GIMME
    Replies:
    3
    Views:
    11,921
    vforvikash
    Dec 29, 2008
Loading...

Share This Page