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

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

Expand Messages
  • acumming@cwnet.com
    ... and advanced Perl programming things such as: packages, namespaces, references, complex data structures, and perhaps now not too far away on the horizon:
    Message 1 of 5 , May 11, 2005
    • 0 Attachment
      On Wed, 11 May 2005 10:40 , Sheri <silvermoonwoman@...> sent:

      >At 06:07 PM 5/7/2005 -0700, you wrote:
      >>Hi Daniel,
      >>
      >>I'm certainly no guru. But am recently leave the basics behind for intermediate
      and advanced Perl programming things such as: packages, namespaces, references,
      complex data structures, and perhaps now not too far away on the horizon: Perl
      Object Oriented programming.
      >
      >LOL! I've forgotten everything I'm so out of practice I've forgotten everything I
      knew.

      Hi! Well it's good to hear your voice on the list once again!

      I'm a couple years behind schedule. But I must be facsinated (sp) with the
      capabilities of Perl: enough familiarity with it then often equates to like "abbra
      cadabbra" sorts of things/capabilities.

      (See next too). But probably what it was doing with the for loop in it is that it
      was just doing one loop then finishing, ie processes all replacements in the first
      loop resulting in it's completed which in turn results in exiting the for loop so
      that therefore the for loop was/is not even needed. Ok, the gurus didn't have time
      to look or else perhaps they would have pointed that out to me.

      The good news is that I'm beginning to catch my own.

      (I'll try to remember to test this when I get on my other machine) 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

      (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

      Alan.




      ---- Msg sent via CWNet - http://www.cwnet.com/
    • 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 2 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.