If the earlier replies did not resolve the problem, then something besides the RE is faulty.

Perhaps the output you are examining did not come from the result of the RE, due to an intervening localization of $_. Also, some output (NUL, etc.) is not visible in some terminals or editors.

Try dumping $_ immediately before and after the RE. Data::Dumper, with its 'qq' mode turned on, will expand any oddball characters into readable forms.

#!/usr/bin/perl -w use strict; use Data::Dumper; $Data::Dumper::Useqq = 1; $_ = join '', <DATA>; print "\nBefore: ", Dumper($_); $_ =~ s/<IT>\s*<\/IT>//gi; print "\nAfter: ", Dumper($_); __DATA__ Foo<iT></It>Bar Baz<it>!</it>Qux
Output:
Before: $VAR1 = "Foo<iT></It>Bar\nBaz<it>!</it>Qux\n"; After: $VAR1 = "FooBar\nBaz<it>!</it>Qux\n";

In reply to Re: Regular Expression by Util
in thread Regular Expression by perlinit

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.