Community
    • Login

    Help with regex: bug?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 581 Views 1 Watching
    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 Offline
      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 Offline
        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 Offline
          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 Offline
            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

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors