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

Re: [Clip] best way to substitute a list of items

Expand Messages
  • Flo
    ... What about this... ^!Set %gender%=^?{Gender is...==_F|M} ^!Replace (?| x20(R)elay| x20(H)urdles| x20Run| x20Dash) $1 AWRS ^!If ^%gender%=M Next Else
    Message 1 of 9 , May 1, 2009
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, Sheri <silvermoonwoman@...> wrote:
      >
      > Sorry I pressed Send before I was finished.
      >
      > ^!Replace "(?J)( (?<m>R)elay| (?<m>H)urdles| (?<m>)Run| (?<m>)Dash)" >>
      > "$<m>" RAWS0
      >
      > Starting Document text:
      >
      > 3200 Relay
      > 300 Hurdles
      > 400 Run
      > 100 Run
      > 100/110 HH
      >
      > After the replace is:
      >
      > 3200R
      > 300H
      > 400
      > 100
      > 100/110 HH
      >
      > Regards,
      > Sheri


      What about this...

      ^!Set %gender%=^?{Gender is...==_F|M}
      ^!Replace "(?|\x20(R)elay|\x20(H)urdles|\x20Run|\x20Dash)" >> "$1" AWRS
      ^!If ^%gender%=M Next Else Skip_2
      ^!Replace "^\d+/(\d+)\x20HH$" >> "$1H" AWRS
      ^!Goto End
      ^!Replace "^(\d+)/\d+\x20HH$" >> "$1H" AWRS

      Sheri uses (?J) which allows duplicate subpattern names. Just for a change, I tried (?| which allows duplicate subpattern numbers. I hope it will survive Sheri's critical eye ;-)

      I also tried to solve the "gender problem" that Don described in his first message.

      Flo
    • Sheri
      ... Thanks Flo, you taught me some things :) For one, I thought it was necessary to capture the empty string or the token in the replacement string would be
      Message 2 of 9 , May 1, 2009
      • 0 Attachment
        --- In ntb-clips@yahoogroups.com, "Flo" <flo.gehrke@...> wrote:
        >
        > --- In ntb-clips@yahoogroups.com, Sheri <silvermoonwoman@> wrote:
        > >
        > > Sorry I pressed Send before I was finished.
        > >
        > > ^!Replace "(?J)( (?<m>R)elay| (?<m>H)urdles| (?<m>)Run| (?<m>)Dash)" >>
        > > "$<m>" RAWS0
        > >
        > > Starting Document text:
        > >
        > > 3200 Relay
        > > 300 Hurdles
        > > 400 Run
        > > 100 Run
        > > 100/110 HH
        > >
        > > After the replace is:
        > >
        > > 3200R
        > > 300H
        > > 400
        > > 100
        > > 100/110 HH
        > >
        > > Regards,
        > > Sheri
        >
        >
        > What about this...
        >
        > ^!Set %gender%=^?{Gender is...==_F|M}
        > ^!Replace "(?|\x20(R)elay|\x20(H)urdles|\x20Run|\x20Dash)" >> "$1" AWRS
        > ^!If ^%gender%=M Next Else Skip_2
        > ^!Replace "^\d+/(\d+)\x20HH$" >> "$1H" AWRS
        > ^!Goto End
        > ^!Replace "^(\d+)/\d+\x20HH$" >> "$1H" AWRS
        >
        > Sheri uses (?J) which allows duplicate subpattern names. Just for a change, I tried (?| which allows duplicate subpattern numbers. I hope it will survive Sheri's critical eye ;-)
        >
        > I also tried to solve the "gender problem" that Don described in his first message.
        >
        > Flo
        >

        Thanks Flo, you taught me some things :)

        For one, I thought it was necessary to capture the empty string or the token in the replacement string would be not work properly. For another I didn't even know about ?|

        Regards,
        Sheri
      • Alec Burgess
        Sheri (silvermoonwoman@comcast.net) wrote (in part) (on 2009-05-01 at ... Flo and Sheri - you are both scary good :-) Current documentation for Notetab
        Message 3 of 9 , May 2, 2009
        • 0 Attachment
          Sheri (silvermoonwoman@...) wrote (in part) (on 2009-05-01 at
          23:40):
          > Thanks Flo, you taught me some things :) For one, I thought it was
          > necessary to capture the empty string or the token in the replacement
          > string would be not work properly. For another I didn't even know
          > about ?|

          Flo and Sheri - you are both scary good :-)
          Current documentation for Notetab regular expressions: Regex.chm (mine
          is dated Friday, March 27, 2009, 05:08:00) includes:

          (?| - DUPLICATE SUBPATTERN NUMBERS it says introduced with Perl 5.10)
          but does not include any mention I could find of
          (?N option - allow duplicate names

          from the Regex.chm we have:
          > INTERNAL OPTION SETTING
          >
          > The settings of the PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, and
          > PCRE_EXTENDED options (which are Perl-compatible) can be changed from
          > within the pattern by a sequence of Perl option letters enclosed
          > between "(?" and ")". The option letters are
          >
          > i for PCRE_CASELESS
          > m for PCRE_MULTILINE
          > s for PCRE_DOTALL
          > x for PCRE_EXTENDED

          In http://www.pcre.org/pcre.txt we have:
          > OPTION SETTING
          >
          > (?i) caseless
          > (?J) allow duplicate names
          > (?m) multiline
          > (?s) single line (dotall)
          > (?U) default ungreedy (lazy)
          > (?x) extended (ignore white space)
          > (?-...) unset option(s)
          I'm confused .... ?
          Unfortunately neither (?| nor (?J appears to be supported in current
          RegexBuddy - I think its still a couple of versions behind in its PCRE
          support / (emulation?)

          --
          Regards ... Alec (buralex@gmail & WinLiveMess - alec.m.burgess@skype)




          [Non-text portions of this message have been removed]
        Your message has been successfully submitted and would be delivered to recipients shortly.