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

Character class question

Expand Messages
  • John Shotsky
    ... I wrote a clip to remove those characters entirely, but it fails with a syntax error. ^!Replace ^[: ]+ ARSW When it displays the syntax error, the
    Message 1 of 5 , Feb 17, 2014
    • 0 Attachment

      I have some text in which some lines start with spaces, sometimes with a colon somewhere in the middle of the spaces like:

              :      Start of text.

      I wrote a clip to remove those characters entirely, but it fails with a syntax error.

      ^!Replace "^[: ]+" >> "" ARSW

      When it displays the syntax error, the left bracket is missing.

      I've tried reversing the space and colon, and I've tried escaping the colon, but it continues to cause a syntax error.

      I've even tried isolating the colon with spaces on both sides, but that still doesn't help:

      ^!Replace "^[\x20:\x20]+" >> "" ARSW

      Always, the left bracket is missing in the error message.

      If I add parens into the clip, it works as expected, but of course that means it is capturing something that is simply going to be deleted.

      ^!Replace "^([: ]+)" >> "" ARSW

      Does anyone understand why this is happening?

      Regards,
      John

    • Axel Berger
      ... That s what I d have suggested and not cared about the capturing. If you can be sure the colon is never the first character but always preceded by a space
      Message 2 of 5 , Feb 17, 2014
      • 0 Attachment
        John Shotsky wrote:
        > If I add parens into the clip, it works as expected,

        That's what I'd have suggested and not cared about the capturing. If you
        can be sure the colon is never the first character but always preceded by a
        space you could make it

        ^!Replace "^ [: ]+" >> "" ARSW

        Axel
      • John Shotsky
        I m more concerned about understanding why this is happening. I use character classes a lot, and don t understand why this one doesn t work. I already have a
        Message 3 of 5 , Feb 17, 2014
        • 0 Attachment

          I'm more concerned about understanding why this is happening. I use character classes a lot, and don't understand why this one doesn't work. I already have a workaround, but this is either a bug, or I need an understanding of what is happening, so I can avoid it in the future. It just 'happens' to be spaces and colons this time, next time it could be something else.

           

          Regards,
          John
          RecipeTools Web Site: http://recipetools.gotdns.com/
          John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

           

          From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Axel Berger
          Sent: Monday, February 17, 2014 09:43
          To: ntb-clips@yahoogroups.com
          Subject: Re: [Clip] Character class question

           

           

          John Shotsky wrote:

          > If I add parens into the clip, it works as expected,

          That's what I'd have suggested and not cared about the capturing. If you
          can be sure the colon is never the first character but always preceded by a
          space you could make it

          ^!Replace "^ [: ]+" >> "" ARSW

          Axel

        • flo.gehrke
          ... Sorry, no idea. For me, ^[: ]+ is working fine, and there is no syntax error in this. BTW... ... This is confusing a Character Class and a pattern being
          Message 4 of 5 , Feb 17, 2014
          • 0 Attachment
            ---In ntb-clips@yahoogroups.com, <jshotsky@...> wrote:
            > I have some text in which some lines start with spaces, (...)
            > like:

            >        :      Start of text.


            Sorry, no idea. For me, '^[: ]+' is working fine, and there is no syntax error in this.

            BTW...
            > I've even tried isolating the colon with spaces on both sides,
            > but that still doesn't help:
            >
            > ^!Replace "^[\x20:\x20]+" >> "" ARSW

            This is confusing a Character Class and a pattern being defined as a specific sequence of characters. A Character Class just defines characters to be matched regardless of the position they have in the target string. So its useless to put a space twice in that Class.

            Regards,
            Flo

          • John Shotsky
            I realize that the redundancy has no meaning, I was just trying to make sure the colon was not touching a bracket. On my computer, even after rebooting, I
            Message 5 of 5 , Feb 17, 2014
            • 0 Attachment

              I realize that the redundancy has no meaning, I was just trying to make sure the colon was not 'touching' a bracket. On my computer, even after rebooting, I get the syntax error, and the left bracket is missing which is confusing to me. I'll try it with a few more characters that I know won't be present, and see if there is any combination that works while still including the colon and spaces. Still - I don't understand what causes it, so I can't avoid it in the future.

              I don't even have to have the subject text present - it happens on any text, like a plain old sentence.

               

              Regards,
              John
              RecipeTools Web Site: http://recipetools.gotdns.com/
              John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

               

              From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of flo.gehrke@...
              Sent: Monday, February 17, 2014 09:52
              To: ntb-clips@yahoogroups.com
              Subject: [Clip] RE: Character class question

               

               

              ---In ntb-clips@yahoogroups.com, <jshotsky@...> wrote:

              > I have some text in which some lines start with spaces, (...)

              > like:

              >        :      Start of text.

               

              Sorry, no idea. For me, '^[: ]+' is working fine, and there is no syntax error in this.

              BTW...

              > I've even tried isolating the colon with spaces on both sides,
              > but that still doesn't help:
              >
              > ^!Replace "^[\x20:\x20]+" >> "" ARSW

              This is confusing a Character Class and a pattern being defined as a specific sequence of characters. A Character Class just defines characters to be matched regardless of the position they have in the target string. So its useless to put a space twice in that Class.

              Regards,
              Flo

            Your message has been successfully submitted and would be delivered to recipients shortly.