Community
    • Login

    Help with regex: bug?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 282 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Monospace-VM
      Monospace-V
      last edited by Monospace-V

      I feel like something is going wrong with my regex search in notepad++. It looks like a bug but I want to know if it’s a problem in my query. My query is highlighting something it is not supposed to.
      My query:

      \b([A-Z]([A-Za-z]*)\.[a-zA-Z_-][a-zA-Z_-]*)
      

      essentially, it should start with capital letter, then have any letters after it, a dot, and then any function call name.
      My query is highlighting an instance that doesn’t start with a capital letter and I don’t know how to stop it.
      Wrongly highlighting:

      session.issued
      

      in

      if session.issued==max_issued:
      

      This happens with EnhanceAnyLexer and N++ search. Checking on online regex testers this isn’t the case: see regexr.com/7nu78
      See screenshots too.
      (I know that I can modify my query for [^=] to temporarily fix this, but that doesn’t solve the issue of unexpected regex behaviour.)
      My version: 8.5.8
      Would appreciate help here. Thanks!

      4f42c346-aca8-41d0-8942-6d23fa49a490-image.png
      20e0e8c4-49bf-41e6-979d-a1802d7d69ed-image.png

      Terry RT 1 Reply Last reply Reply Quote 0
      • Terry RT
        Terry R @Monospace-V
        last edited by

        @Monospace-V
        By default the regex engine is case insensitive meaning a-z and A-Z are the same. You need to use a modifier before the expression to make it see capitals only when using A-Z. Look at (?-i). Search posts on this forum as there are lots of expressions using this where the case is important.

        Sorry I’m typing this on a phone so hard to find and post links

        Terry

        Monospace-VM 1 Reply Last reply Reply Quote 2
        • Monospace-VM
          Monospace-V @Terry R
          last edited by

          @Terry-R found. Fixed. Thanks for the info; it did not occur that a language like regex with separate options for uppercase and lowercase could have any case insensitivity enabled by default.

          Alan KilbornA 1 Reply Last reply Reply Quote 2
          • Alan KilbornA
            Alan Kilborn @Monospace-V
            last edited by

            By default the regex engine is case insensitive meaning a-z and A-Z are the same.

            it did not occur (to me) that a language like regex with separate options for uppercase and lowercase could have any case insensitivity enabled by default.

            It actually isn’t case sensitive by default. But because the Notepad++ user interface to searching has a Match case checkbox, the state of that become part of the operation. If uncheckmarked when the operation starts, then, well…

            For regex purists, perhaps always starting your regex with (?-i) – which overrides the state of the Match case checkbox – is the way to go.

            1 Reply Last reply Reply Quote 4
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors