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

[Clip] Re: Please, why doesn't this match ?!?!?

Expand Messages
  • janderri
    Just one more question, the regular expressions and replace commands are really clumsy laid out in the help file. For example : ^!Replace . Rik . RIk
    Message 1 of 22 , Feb 3, 2008
      Just one more question, the regular expressions and replace commands are really clumsy laid out in the help file.

      For example : ^!Replace "\.\Rik" >> "\.\RIk" ATWR

      Why doesn't this replace :

      "
      someline.
      ik something here.
      "

      with :
      "
      someline.
      Ik something here.
      "

      instead it does this (doesn't care about the regular expression \R which is newline)

      "
      someline.RIk something here.
      "

      Please how I can make it do a newline in the replacement command ?
      TIA!


      --- In ntb-clips@yahoogroups.com, "janderri" <jan_derrick@...> wrote:
      >
      > Nice ! Learning all day !
      >
      > Thanks dracorat !
      >
      >
      > --- In ntb-clips@yahoogroups.com, "dracorat" <dracorat@> wrote:
      > >
      > > I would also like to point out you could combine your two lines to one:
      > > ^!Replace "^(-)?Ak(\s)" >> "$1Ik$2" ATWSR
      > >
      > > Hope this helps!
      > >
      > > --Keith Ratliff
      > >
      > >
      > > --- In ntb-clips@yahoogroups.com, hsavage <hsavage@> wrote:
      > > >
      > > > janderri wrote:
      > > > > --- In ntb-clips@yahoogroups.com, Sheri <silvermoonwoman@> wrote:
      > > > >> janderri wrote:
      > > > >>> Hi,
      > > > >>>
      > > > >>> I have a script like this :
      > > > >>>
      > > > >>> ^!Replace "^Ak(\s)" >> "Ik$1" ATWS
      > > > >>> ^!Replace "^-Ak(\s)" >> "-Ik$1" ATWS
      > > > >>>
      > > > >> You need an "R" in your options for regular expressions. "T" btw
      > > has no
      > > > >> effect when "R" is used.
      > > > >>
      > > > >> Please address any followup or other clip questions to the clips
      > > list.
      > > > >>
      > > > >> Regards,
      > > > >> Sheri
      > > > >>
      > > > > Tried it with R option included, still doesn't work.
      > > >
      > > > janderri,
      > > >
      > > > These are the same 2 lines posted previously, they worked after adding
      > > > an 'R' to the settings and deleting the extra Tab in the first
      > > ^!Replace
      > > > line. In the original email the first line had a Tab preceding the
      > > > double chevron.
      > > >
      > > > ·············································
      > > > ºvº SL-01-198 -created- 2008.01.25 - 17.59.14
      > > >
      > > > Rules guys wish girls knew...
      > > > "Crying is blackmail.
      > > > Use it if you must, but don't expect us to like it."
      > > > ¤ ø ¤ hrs ø hsavage@
      > > >
      > >
      >
    • janderri
      Also does anyone know what the OR operator is in a find/replace function ? so, Find a OR b ?
      Message 2 of 22 , Feb 3, 2008
        Also does anyone know what the OR operator is in a find/replace function ?

        so, Find a OR b

        ?



        --- In ntb-clips@yahoogroups.com, "janderri" <jan_derrick@...> wrote:
        >
        > Just one more question, the regular expressions and replace commands are really clumsy laid out in the help file.
        >
        > For example : ^!Replace "\.\Rik" >> "\.\RIk" ATWR
        >
        > Why doesn't this replace :
        >
        > "
        > someline.
        > ik something here.
        > "
        >
        > with :
        > "
        > someline.
        > Ik something here.
        > "
        >
        > instead it does this (doesn't care about the regular expression \R which is newline)
        >
        > "
        > someline.RIk something here.
        > "
        >
        > Please how I can make it do a newline in the replacement command ?
        > TIA!
        >
        >
        > --- In ntb-clips@yahoogroups.com, "janderri" <jan_derrick@> wrote:
        > >
        > > Nice ! Learning all day !
        > >
        > > Thanks dracorat !
        > >
        > >
        > > --- In ntb-clips@yahoogroups.com, "dracorat" <dracorat@> wrote:
        > > >
        > > > I would also like to point out you could combine your two lines to one:
        > > > ^!Replace "^(-)?Ak(\s)" >> "$1Ik$2" ATWSR
        > > >
        > > > Hope this helps!
        > > >
        > > > --Keith Ratliff
        > > >
        > > >
        > > > --- In ntb-clips@yahoogroups.com, hsavage <hsavage@> wrote:
        > > > >
        > > > > janderri wrote:
        > > > > > --- In ntb-clips@yahoogroups.com, Sheri <silvermoonwoman@> wrote:
        > > > > >> janderri wrote:
        > > > > >>> Hi,
        > > > > >>>
        > > > > >>> I have a script like this :
        > > > > >>>
        > > > > >>> ^!Replace "^Ak(\s)" >> "Ik$1" ATWS
        > > > > >>> ^!Replace "^-Ak(\s)" >> "-Ik$1" ATWS
        > > > > >>>
        > > > > >> You need an "R" in your options for regular expressions. "T" btw
        > > > has no
        > > > > >> effect when "R" is used.
        > > > > >>
        > > > > >> Please address any followup or other clip questions to the clips
        > > > list.
        > > > > >>
        > > > > >> Regards,
        > > > > >> Sheri
        > > > > >>
        > > > > > Tried it with R option included, still doesn't work.
        > > > >
        > > > > janderri,
        > > > >
        > > > > These are the same 2 lines posted previously, they worked after adding
        > > > > an 'R' to the settings and deleting the extra Tab in the first
        > > > ^!Replace
        > > > > line. In the original email the first line had a Tab preceding the
        > > > > double chevron.
        > > > >
        > > > > ·············································
        > > > > ºvº SL-01-198 -created- 2008.01.25 - 17.59.14
        > > > >
        > > > > Rules guys wish girls knew...
        > > > > "Crying is blackmail.
        > > > > Use it if you must, but don't expect us to like it."
        > > > > ¤ ø ¤ hrs ø hsavage@
        > > > >
        > > >
        > >
        >
      • buralex@gmail.com
        janderri said on Feb 03, 2008 15:06 -0500 ... R (meaning any linefeed matching either r n or just n depending on file format) is
        Message 3 of 22 , Feb 3, 2008
          "janderri" <jan_derrick@...> said on Feb 03, 2008 15:06 -0500
          (in part):
          > Just one more question, the regular expressions and replace commands
          > are really clumsy laid out in the help file.
          >
          > For example : ^!Replace "\.\Rik" >> "\.\RIk" ATWR
          \R (meaning any linefeed matching either \r\n or just \n depending on
          file format) is only active on the left side. If you want a linefeed
          inserted in the replacement use "\r\n".

          so: ^!Replace "\.\Rik" >> "\.\r\nIk" ATWR
          also: "." only has special meaning on the find side (necessitating
          escaping it as \.). On the replace side "." is just a regular character
          so it doesn't need to be escaped.
          hence: ^!Replace "\.\Rik" >> ".\r\nIk" ATWR

          Regards ... Alec -- buralex-gmail
          --



          [Non-text portions of this message have been removed]
        • janderri
          ... http://www.flash-fun.com/html/thankyou.php
          Message 4 of 22 , Feb 3, 2008
            --- In ntb-clips@yahoogroups.com, buralex@... wrote:
            >
            > "janderri" <jan_derrick@...> said on Feb 03, 2008 15:06 -0500
            > (in part):
            > > Just one more question, the regular expressions and replace commands
            > > are really clumsy laid out in the help file.
            > >
            > > For example : ^!Replace "\.\Rik" >> "\.\RIk" ATWR
            > \R (meaning any linefeed matching either \r\n or just \n depending on
            > file format) is only active on the left side. If you want a linefeed
            > inserted in the replacement use "\r\n".
            >
            > so: ^!Replace "\.\Rik" >> "\.\r\nIk" ATWR
            > also: "." only has special meaning on the find side (necessitating
            > escaping it as \.). On the replace side "." is just a regular character
            > so it doesn't need to be escaped.
            > hence: ^!Replace "\.\Rik" >> ".\r\nIk" ATWR
            >
            > Regards ... Alec -- buralex-gmail
            > --
            >
            >
            >
            > [Non-text portions of this message have been removed]
            >

            http://www.flash-fun.com/html/thankyou.php
          • dracorat
            Actually I think the capitalization may be the issue. Even with ignore case - the case of the slash command matters. r matches ends of lines R matches
            Message 5 of 22 , Feb 4, 2008
              Actually I think the capitalization may be the issue. Even with
              "ignore case" - the case of the slash command matters. \r matches ends
              of lines \R matches everything EXCEPT ends of lines.

              As for the other question on how to do ORs-

              If it's only one letter, place it in a bracket:

              ([ab]) matches a or b

              If it's whole sequences place them in a (?: ... ) series (for each)
              separated by a pipe (|)

              So,

              ((?:Clarissa)|(?:Claire)) matches "Clarissa" or "Claire" but nothing else.

              --Keith

              --- In ntb-clips@yahoogroups.com, buralex@... wrote:
              >
              > "janderri" <jan_derrick@...> said on Feb 03, 2008 15:06 -0500
              > (in part):
              > > Just one more question, the regular expressions and replace commands
              > > are really clumsy laid out in the help file.
              > >
              > > For example : ^!Replace "\.\Rik" >> "\.\RIk" ATWR
              > \R (meaning any linefeed matching either \r\n or just \n depending on
              > file format) is only active on the left side. If you want a linefeed
              > inserted in the replacement use "\r\n".
              >
              > so: ^!Replace "\.\Rik" >> "\.\r\nIk" ATWR
              > also: "." only has special meaning on the find side (necessitating
              > escaping it as \.). On the replace side "." is just a regular character
              > so it doesn't need to be escaped.
              > hence: ^!Replace "\.\Rik" >> ".\r\nIk" ATWR
              >
              > Regards ... Alec -- buralex-gmail
              > --
              >
              >
              >
              > [Non-text portions of this message have been removed]
              >
            • Sheri
              ... Hi Keith, There are a few metacharacters that are like that (where the capital version is opposite the lowercase version), but not true of r . Backslash-R
              Message 6 of 22 , Feb 4, 2008
                dracorat wrote:
                > Actually I think the capitalization may be the issue. Even with
                > "ignore case" - the case of the slash command matters. \r matches ends
                > of lines \R matches everything EXCEPT ends of lines.
                >

                Hi Keith,

                There are a few metacharacters that are like that (where the capital
                version is opposite the lowercase version), but not true of "r".

                Backslash-R is a metacharacter for:| "(?>\r\n|[\r\n])"|.

                You can cause it to match: |"(?>\r\n|\n|\x0b|\f|\r|\x85)"

                instead by including (*BSR_UNICODE) at the start of a pattern.|

                Dot is what matches everything but line breaks (unless the ?s option is
                used).

                Backslash-R was not a metacharacter in PCRE versions earlier than 7.0.
                It is only since PCRE 7.4 that there are alternative meanings for \R. In
                7.0-7.3, it matched only the unicode version.

                Regards,
                Sheri
              • Sheri
                ... Strange, I m seeing irrelevant vertical bars in quoted text above, somehow inserted from my email app (thunderbird). Above should say: Backslash-R is a
                Message 7 of 22 , Feb 4, 2008
                  --- In ntb-clips@yahoogroups.com, Sheri <silvermoonwoman@...> wrote:
                  >
                  > Backslash-R is a metacharacter for:| "(?>\r\n|[\r\n])"|.
                  >
                  > You can cause it to match: |"(?>\r\n|\n|\x0b|\f|\r|\x85)"
                  >
                  > instead by including (*BSR_UNICODE) at the start of a pattern.|


                  Strange, I'm seeing irrelevant vertical bars in quoted text above,
                  somehow inserted from my email app (thunderbird).

                  Above should say:

                  Backslash-R is a metacharacter for: "(?>\r\n|[\r\n])"

                  You can cause it to match: "(?>\r\n|\n|\x0b|\f|\r|\x85)"

                  instead by including (*BSR_UNICODE) at the start of a pattern.

                  Regards,
                  Sheri
                • dracorat
                  As long as you are still using regular expressions, it s the answer I gave before. Namely: One-character ORs are done with a bracketed pair: [ab] Matches a or
                  Message 8 of 22 , Feb 7, 2008
                    As long as you are still using regular expressions, it's the answer I
                    gave before. Namely:

                    One-character ORs are done with a bracketed pair:
                    [ab]
                    Matches a or b

                    Multiple-character ORs are done with a non-capturing group like so:
                    (?:apple)|(?:bannanna)
                    Matche apple or bannanna but not say applanna.

                    In regards to your other question about the replace command and new
                    lines, did it get answered with the prior responses or is it still
                    outstanding?

                    --Keith Ratliff

                    --- In ntb-clips@yahoogroups.com, "janderri" <jan_derrick@...> wrote:
                    >
                    > Also does anyone know what the OR operator is in a find/replace
                    function ?
                    >
                    > so, Find a OR b
                    >
                    > ?
                    >
                    >
                  • leroydennis254
                    Thanks Keith, I m a lot wiser now ! :)
                    Message 9 of 22 , Feb 7, 2008
                      Thanks Keith, I'm a lot wiser now ! :)


                      --- In ntb-clips@yahoogroups.com, "dracorat" <dracorat@...> wrote:
                      >
                      > As long as you are still using regular expressions, it's the answer I
                      > gave before. Namely:
                      >
                      > One-character ORs are done with a bracketed pair:
                      > [ab]
                      > Matches a or b
                      >
                      > Multiple-character ORs are done with a non-capturing group like so:
                      > (?:apple)|(?:bannanna)
                      > Matche apple or bannanna but not say applanna.
                      >
                      > In regards to your other question about the replace command and new
                      > lines, did it get answered with the prior responses or is it still
                      > outstanding?
                      >
                      > --Keith Ratliff
                      >
                      > --- In ntb-clips@yahoogroups.com, "janderri" <jan_derrick@> wrote:
                      > >
                      > > Also does anyone know what the OR operator is in a find/replace
                      > function ?
                      > >
                      > > so, Find a OR b
                      > >
                      > > ?
                      > >
                      > >
                      >
                    • Flo
                      ... Keith, ... Isn t it more a matter of style to use non-capturing groups here than a demand of logical OR? I learned from Jeffrey Friedl that it s more a
                      Message 10 of 22 , Feb 8, 2008
                        --- In ntb-clips@yahoogroups.com, "dracorat" <dracorat@...> wrote:...

                        Keith,

                        > Multiple-character ORs are done with a non-capturing group like
                        > so: (?:apple)|(?:bannanna)

                        Isn't it more a matter of "style" to use non-capturing groups here
                        than
                        a demand of logical OR? I learned from Jeffrey Friedl that it's more
                        a
                        side effect of (?:) to save run time and memory (since the contents
                        of
                        these brackets isn't stored). Maybe this has an effect with very big
                        files.

                        IMHO even the grouping is not essential. Also "apple|banana" would
                        match here (or more precisely: "bannanna").

                        To add to your examples: Also a simple question mark can make an OR,
                        e.g. "Alfredo?" matches "Alfred" OR "Alfredo".

                        Regards,
                        Flo
                      • Axel Berger
                        ... That too. What makes it attractive to me is the difficulty of counting nested brackets correctly. If you only need to count the relevant ones, it is much
                        Message 11 of 22 , Feb 8, 2008
                          Flo wrote:
                          > I learned from Jeffrey Friedl that it's more a
                          > side effect of (?:) to save run time and memory

                          That too. What makes it attractive to me is the difficulty of counting
                          nested brackets correctly. If you only need to count the relevant ones,
                          it is much easier to get the right n in $n for replacement.

                          Axel
                        • Sheri
                          ... There is definitely no requirement to make each alternative into a subpattern. If you choose to make them subpatterns, I would recommend making them
                          Message 12 of 22 , Feb 8, 2008
                            --- In ntb-clips@yahoogroups.com, "Flo" <flo.gehrke@...> wrote:
                            >
                            > --- In ntb-clips@yahoogroups.com, "dracorat" <dracorat@> wrote:...
                            >
                            > Keith,
                            >
                            > > Multiple-character ORs are done with a non-capturing group like
                            > > so: (?:apple)|(?:bannanna)
                            >
                            > Isn't it more a matter of "style" to use non-capturing groups
                            > here than a demand of logical OR? I learned from Jeffrey Friedl
                            > that it's more a side effect of (?:) to save run time and memory
                            > (since the contents of these brackets isn't stored). Maybe this
                            > has an effect with very big files.
                            >
                            > IMHO even the grouping is not essential. Also "apple|banana" would
                            > match here (or more precisely: "bannanna").

                            There is definitely no requirement to make each alternative into a
                            subpattern. If you choose to make them subpatterns, I would recommend
                            making them non-capturing in NoteTab's present implementation. Among
                            alternatives, only one choice will be set and all others unset.
                            NoteTab currently has issues with unset substrings.

                            But capturing multiple substrings where one or more will be unset is
                            usually not desired anyway. If anything, you would usually want to
                            retrieve the overall result among alternatives, which can be achieved
                            by surrounding the whole group with parentheses: (apple|bandanna). If
                            that were the whole pattern no parenthesized subpatterns would be
                            needed because the result would be the whole match.

                            Regards,
                            Sheri
                          • dracorat
                            Consider myself educated by your post! I did a word|secondword before and whatever version of Regular Expressions I was using made the | evaluate only the
                            Message 13 of 22 , Feb 8, 2008
                              Consider myself educated by your post!

                              I did a word|secondword before and whatever version of Regular
                              Expressions I was using made the | evaluate only the letters beside
                              the pipe. Thus in the example of apple|bannanna (whoops on my previous
                              spelling btw) it would only match:

                              appleannanna or applbannanna

                              But, I just tested your post and it certainly (at least in this
                              version of PCRE) works just as you describe woot!!

                              Which IMO, looks a lot nicer.

                              So am I correct that the following:

                              Mary went to the store|market\.

                              Would match:
                              Mary went to the market.
                              Mary went to the store.

                              ??

                              --Keith

                              --- In ntb-clips@yahoogroups.com, "Flo" <flo.gehrke@...> wrote:
                              >
                              > --- In ntb-clips@yahoogroups.com, "dracorat" <dracorat@> wrote:...
                              >
                              > Keith,
                              >
                              > > Multiple-character ORs are done with a non-capturing group like
                              > > so: (?:apple)|(?:bannanna)
                              >
                              > Isn't it more a matter of "style" to use non-capturing groups here
                              > than
                              > a demand of logical OR? I learned from Jeffrey Friedl that it's more
                              > a
                              > side effect of (?:) to save run time and memory (since the contents
                              > of
                              > these brackets isn't stored). Maybe this has an effect with very big
                              > files.
                              >
                              > IMHO even the grouping is not essential. Also "apple|banana" would
                              > match here (or more precisely: "bannanna").
                              >
                              > To add to your examples: Also a simple question mark can make an OR,
                              > e.g. "Alfredo?" matches "Alfred" OR "Alfredo".
                              >
                              > Regards,
                              > Flo
                              >
                            • Axel Berger
                              ... I may be totally off track here, but wouldn t it match either Mary went to the store or market. ? Axel
                              Message 14 of 22 , Feb 8, 2008
                                dracorat wrote:
                                > So am I correct that the following:
                                >
                                > Mary went to the store|market\.
                                >
                                > Would match:
                                > Mary went to the market.
                                > Mary went to the store.

                                I may be totally off track here, but wouldn't it match either
                                Mary went to the store
                                or
                                market.
                                ?

                                Axel
                              • dracorat
                                I didn t have time to test this morn before heading to work. And you are right. In order to match tho two sentences you d have to do either: (Mary went to the
                                Message 15 of 22 , Feb 8, 2008
                                  I didn't have time to test this morn before heading to work.

                                  And you are right. In order to match tho two sentences you'd have to
                                  do either:
                                  (Mary went to the store\.|Mary went to the market\.)
                                  OR
                                  (Mary went to the (?:store|market)\.)

                                  Thanks for the lessons. (See, even old dogs [technology wise anyway]
                                  can learn new tricks.)

                                  --Keith

                                  --- In ntb-clips@yahoogroups.com, Axel Berger <Axel-Berger@...> wrote:
                                  >
                                  > dracorat wrote:
                                  > > So am I correct that the following:
                                  > >
                                  > > Mary went to the store|market\.
                                  > >
                                  > > Would match:
                                  > > Mary went to the market.
                                  > > Mary went to the store.
                                  >
                                  > I may be totally off track here, but wouldn't it match either
                                  > Mary went to the store
                                  > or
                                  > market.
                                  > ?
                                  >
                                  > Axel
                                  >
                                Your message has been successfully submitted and would be delivered to recipients shortly.