Community
    • Login

    need help to look for a word

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    10 Posts 5 Posters 278 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.
    • Alex Yuan -CAA
      Alex Yuan -CA
      last edited by

      so i need to look for a word, lets say the word is interface, it would find it but also it won’t.

      in the big garble of words in the text file it could look like the below:

      192.168.1.1;interface
      192.168.1.3interface

      Presently it would find and highlight the word interface from 192.168.1.1;interface but not from 192.168.1.3interface, without the semi colon.

      What Im trying to get help with is, find any interface name without semi colon in front

      Alan KilbornA 3 Replies Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Alex Yuan -CA
        last edited by

        @Alex-Yuan-CA said in need help to look for a word:

        find and highlight the word interface from 192.168.1.1;interface but not from 192.168.1.3interface,

        You probably have this setting checkmarked:

        391aa5f3-91fa-47d5-aaae-698b6fb2efdf-image.png

        Uncheckmark it.


        The software sometimes even gives you instruction about this:

        d6a5c33d-1261-45df-8a7b-ba1eae65e5ad-image.png

        1 Reply Last reply Reply Quote 3
        • mathlete2M
          mathlete2
          last edited by

          @Alex-Yuan-CA in case you are trying to simply use in-document highlighting instead of the Find window, there are similar options in the Highlighting section of the Preferences window (Settings > Preferences…):

          0b92083d-6823-4bf6-add0-9955c21e618f-image.png

          1 Reply Last reply Reply Quote 1
          • Alan KilbornA
            Alan Kilborn @Alex Yuan -CA
            last edited by

            @Alex-Yuan-CA

            In case you are trying to do any other possible text manipulation, searching, highlighting, etc, etc, or anything you can possibly think of doing to your text, please consult the Notepad++ online user manual, because your answer is probably found there.

            dr ramaanandD 1 Reply Last reply Reply Quote 2
            • dr ramaanandD
              dr ramaanand @Alan Kilborn
              last edited by dr ramaanand

              @Alex-Yuan-CA If you open the Find/Replace pop up and select the Regular expression mode at the bottom and type ;interface(*SKIP)(*FAIL)|;interface you will find all of them (skipping the preceding ;) upon hitting the Find button. An explanation for this method of regular expression (RegEx) can be found at https://community.notepad-plus-plus.org/topic/26812/generic-regex-how-to-use-the-couple-of-backtracking-control-verbs-skip-fail-or-skip-f-in-regexes

              1 Reply Last reply Reply Quote 0
              • Alan KilbornA
                Alan Kilborn @Alex Yuan -CA
                last edited by

                @Alex-Yuan-CA said:

                What Im trying to get help with is, find any interface name without semi colon in front

                @dr-ramaanand said:

                ;interface(*SKIP)(*FAIL)|;interface

                @dr-ramaanand Does this meet the need?

                dr ramaanandD 1 Reply Last reply Reply Quote 0
                • dr ramaanandD
                  dr ramaanand @Alan Kilborn
                  last edited by dr ramaanand

                  @Alan-Kilborn Sorry, that should be ;interface(*SKIP)(*FAIL)|interface on Notepad++. I thought I had deleted the last ; (semi-colon) but while pasting it above, I pasted it with it

                  PeterJonesP 1 Reply Last reply Reply Quote 0
                  • PeterJonesP
                    PeterJones @dr ramaanand
                    last edited by PeterJones

                    @dr-ramaanand said in need help to look for a word:

                    @Alan-Kilborn Yes, please check it out on Notepad++

                    ea37eae6-ede6-46a5-bf35-b62ccbead582-image.png

                    It didn’t work. It found 0 matches, when it should have found one. Please be careful when giving advice, that it at least does what you claim it does.

                    This is not a situation where you need the complications of skip/fail. As @Alan-Kilborn showed, it can be done with a simple non-regex search; if it can be done simply, trying to apply the complicated formula is the wrong thing to do. Even with regex, it would be easier in this case to use a fixed positive negative lookbehind (since the semicolon is always one character, you don’t need to worry about variable size, so the Boost regex engine can handle th lookbehind just fine), rather than trying to apply the advanced skip/fail.


                    To future readers: the post I quoted got changed while I was replying to it. Sorry that it makes it look like I was making up quotes. Even after @dr-ramaanand’s change to his post, my claim that this is not a situation where skip/fail is needed still stands.

                    dr ramaanandD 1 Reply Last reply Reply Quote 2
                    • dr ramaanandD
                      dr ramaanand @PeterJones
                      last edited by dr ramaanand

                      @PeterJones If he or anyone else wants to use a negative look behind assertion, he can use the method explained at https://npp-user-manual.org/docs/searching/#assertions in which case, he should use the regular expression (?<!;)interface in the Find field, that is, he should select the regular expression mode in the Find/Replace pop up and use (?<!;)interface in the Find field before he hits the Find/Replace button - it will help find interface if it is not preceded by a ; (semi-colon). I gave him the SKIP/FAIL method of finding that word if it was not preceded by a semi-colon simply because it is easier - please see the explanation at https://community.notepad-plus-plus.org/topic/26812/generic-regex-how-to-use-the-couple-of-backtracking-control-verbs-skip-fail-or-skip-f-in-regexes (if one clicks this link, one can see that it is easier especially because it shows the part skipped and the part matched)

                      PeterJonesP 1 Reply Last reply Reply Quote 0
                      • PeterJonesP
                        PeterJones @dr ramaanand
                        last edited by

                        @dr-ramaanand said in need help to look for a word:

                        simply because it is easier

                        That’s apparently a matter of opinion. To me, negative lookbehind, where it’s telling you “look behind the current position, and make sure it’s not XYZ” is a lot easier to read/understand than “match something, then say, wait no, I don’t actually want to match that, let’s fail this whole path and move on to the alternation”. (And, from what I can tell, that’s not really a good explanation of skip+fail, because it takes our regex guru pages of text to explain it, whereas I can successfully convey the meaning of a negative lookbehind in one sentence.)

                        Since your first version of the skip+fail post was wrong, and you couldn’t tell this immediately, even after it was pointed out to you that it was wrong, I am not convinced that it’s truly as “simple” – even for you – as you are implying.

                        I am going to stick with recommending solutions that i could explain if necessary; I will only personally link to the skip+fail formula if I know of no other way to do something (and I wouldn’t tell anyone it’s “simple”)

                        But if it truly makes more sense to you than a negative lookbehind, that’s great for you; everyone is different.

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