Community
    • Login

    find bug for exact match

    Scheduled Pinned Locked Moved General Discussion
    5 Posts 4 Posters 3.9k 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.
    • ramromailR
      ramromail
      last edited by

      Hi,

      I think this is a bug with notepad++ 7.4.2.
      To reproduce the bug try this,

      1. copy, paste the following four lines into notpad++

        $abc
        $abcd
        ($abc)
        ($abcd)

      2. try to search/find (normal not regex) for $abc, with “Match whole words only option checked” and you will see the match on 3rd line will not be found by notepad++

      Is this a bug or am I missing something here?
      Thanks.

      1 Reply Last reply Reply Quote 0
      • gstaviG
        gstavi
        last edited by

        The definition of “whole word” is fuzzy so it is hard to decide if this is a BUG.
        Specifically the definition of whole word is problematic when the search string by itself contains “special” symbols.

        What symbols are word delimiters?
        Once you added ‘$’ symbol into the search string who can decide if ‘(’ symbol is not a continuation of the same word?
        Which of the following should ‘find $abc’ stop upon?
        $$abc
        $abc$xyz
        _$abc
        a$abc

        Nevertheless, I do agree that likely most users would always consider parentheses symbols as “word breakers”.

        I wonder which of the options (if any) the find algorithm uses with “whole word” enabled:
        [1] Search for search string regardless of words. On match test if whole word.
        [2] Traverse text “word by word” and compare each word against search string.

        Option [1] allows more flexibility in definition of ‘word’. It is easier for it to use search string by itself as criteria for which delimiters are relevant.

        1 Reply Last reply Reply Quote 1
        • ramromailR
          ramromail
          last edited by

          I believe as text editor for coding purposes, (for e.g. incase of C, C++, PHP etc) $ symbol should not be treated as special symbol but as any other character, similarly in other programming language.

          Scott SumnerS 1 Reply Last reply Reply Quote 0
          • Scott SumnerS
            Scott Sumner @ramromail
            last edited by

            @ramromail , @gstavi :

            There is a great discussion (from @guy038) of this behavior here: https://notepad-plus-plus.org/community/topic/13004/bugs-in-normal-search-for-v7-2-2-on-windows-7/4

            My takeaway from that thread is that if you are going to check the Match whole words only checkbox, you should expect “good” behavior from the search only if your first and last characters in the Find what box are “word” characters in the set: A-Z, a-z, 0-9, and _

            If this (or ANY posting on the Notepad++ Community site) is useful, don’t reply with a “thanks”, simply up-vote ( click the ^ in the ^ 0 v area on the right ).

            1 Reply Last reply Reply Quote 0
            • Marcelo FinkielszteinM
              Marcelo Finkielsztein
              last edited by

              [1] Suggested Workaround approach for ramromail:
              Do not use “whole words” options for coding scenarios.
              It seems that the “whole word” definition is too simplistic for your needs. Use regex instead, where you will be able to define separators to you convenience.

              [2] Suggestions for npp coders (Wish list):
              [2.1] When the user picks “whole word”, show “advanced options” for the user to define their own word delimiters.
              [2.2] Or add a config section for word delimiters among the preferences?

              HTH
              Marcelo

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