Loading ...
Sorry, an error occurred while loading the content.

[NTS] Re: [Clip] Use RegExp to change case?

Expand Messages
  • acummingsus
    ... [ . . ] A guru would ... so because of ... goes through the ... for loop from ... think too) 2 ... Oops. I removed the left hand parenthesis but forgot to
    Message 1 of 5 , May 11, 2005
    • 0 Attachment
      --- In ntb-scripts@yahoogroups.com, <acumming@c...> wrote:
      [ . . ] A guru would
      > know -- but likely could do without the for loop and I think it is
      so because of
      > the g (global option) coupled with the regex operator already does
      goes through the
      > entire string, doing all replacements. For example, to remove the
      for loop from
      > the script:
      >
      > for ($text =~ s/(<strong>)(.*?)(<\/strong>)/$1\U$2\E$3/gis) {
      > print $text;
      > } # end
      >
      > So, those 3 lines would then instead become (and more correctly I
      think too) 2
      > lines, thus:
      >
      > $text =~ s/(<strong>)(.*?)(<\/strong>)/$1\U$2\E$3/gis);
      > print $text; # end

      Oops. I removed the left hand parenthesis but forgot to remove the
      one on the right hand side.

      gis) needs to become gis

      $text =~ s/(<strong>)(.*?)(<\/strong>)/$1\U$2\E$3/gis;

      That's the only change, one ) removed. The above line is corrected.
      Alan.
      >
      > (The unmodified original is enclosed next):
      >
      > H="pl_case_changr"
      > ^!RunPerl pl_case_changer
      >
      > H="_pl_case_changer"
      > #!perl -w
      > undef $/; # Enter "file slurp" mode.
      > $text = <>; # This file/buffer/selection slurped into the scalar
      > for ($text =~ s/(<strong>)(.*?)(<\/strong>)/$1\U$2\E$3/gis) {
      > print $text;
      > } # end
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.