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

Re: \W and underscore

Expand Messages
  • flo.gehrke
    ... This is misleading. A single character like the underscore can never be represent a word boundary. b is an assertion that matches at a position where a
    Message 1 of 15 , Mar 16, 2013
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:
      >
      > This also complicates the use of \b for word boundaries,
      > because \b DOES treat this character as a word boundary.

      This is misleading. A single character like the underscore can never be represent a word boundary. '\b' is an assertion that matches at a position where a non-word character is preceded resp. followed by a word character. Thus it signifies a position of zero length and no single character.

      As discussed here, the underscore is defined as a normal word character. So '\bJohn' doesn't match the string 'aaa _John', for example, because 'John' is not preceded by a word boundary in this case.

      Flo
    • Axel Berger
      ... You re absolutely right. I had taken John by his word and not tested this. In the text aaabbbccc aaa bbbccc aaabbb ccc aaa bbb ccc aaa_bbbccc aaabbb_ccc
      Message 2 of 15 , Mar 16, 2013
      • 0 Attachment
        "flo.gehrke" wrote:
        > As discussed here, the underscore is defined as a normal word character.

        You're absolutely right. I had taken John by his word and not tested
        this.

        In the text

        aaabbbccc
        aaa bbbccc aaabbb ccc aaa bbb ccc
        aaa_bbbccc aaabbb_ccc aaa_bbb_ccc
        aaa _bbb ccc aaa bbb_ ccc aaa _bbb_ ccc
        aaa_ bbb_ccc aaa_bbb _ccc aaa_ bbb _ccc

        the pattern "\bbbb\b" (b was a bad letter choice in hindsight) matches
        the last string in the second and in the fifth line, nothing else.

        Axel
      • John Shotsky
        You re right, I was not paying attention. It was selecting the last character, which was the underscore and the boundary was the following character. If you do
        Message 3 of 15 , Mar 17, 2013
        • 0 Attachment
          You're right, I was not paying attention. It was selecting the last character, which was the underscore and the boundary was the
          following character. If you do your test with a space following the underscore, you will see what I mean.

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

          From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Axel Berger
          Sent: Saturday, March 16, 2013 23:51
          To: ntb-clips@yahoogroups.com
          Subject: Re: [Clip] Re: \W and underscore


          "flo.gehrke" wrote:
          > As discussed here, the underscore is defined as a normal word character.

          You're absolutely right. I had taken John by his word and not tested
          this.

          In the text

          aaabbbccc
          aaa bbbccc aaabbb ccc aaa bbb ccc
          aaa_bbbccc aaabbb_ccc aaa_bbb_ccc
          aaa _bbb ccc aaa bbb_ ccc aaa _bbb_ ccc
          aaa_ bbb_ccc aaa_bbb _ccc aaa_ bbb _ccc

          the pattern "\bbbb\b" (b was a bad letter choice in hindsight) matches
          the last string in the second and in the fifth line, nothing else.

          Axel



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