Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a series of XML type tags that I need to remove from a document. A simple regex should do the trick, I just can't figure out what it is.

I need to match the following, where "FOOBAR" can be anything:
<MOD_FOOBAR />
I've attempted to match with the following regex's:
s/^<MOD_.*\s\/>//g; s/^<MOD_.* \/>//g;
But they do not work.

Replies are listed 'Best First'.
Re: regex replacement
by ccn (Vicar) on Sep 17, 2004 at 12:17 UTC

    try to define what does "anything" mean. E.g. non-angles

    s/^<MOD_[^>]+>//g;
      That did it, thanks
Re: regex replacement
by Roy Johnson (Monsignor) on Sep 17, 2004 at 12:24 UTC
    Non-greedy matching ought to fix you up:
    s/^<MOD_.*?\/>//g;

    Caution: Contents may have been coded under pressure.