Community
    • Login

    sample config

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    24 Posts 4 Posters 3.6k 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.
    • PeterJonesP
      PeterJones @PeterJones
      last edited by

      @Justin-Lang,

      Sorry, we got into the weeds. In case it’s not clear to you: Don’t use my first regex; there are too many problems with it.

      Instead, use my second, which works more reliably: (?i-s)\A(^(?!username \S+ password \S+).*$\R*)+\z.

      Also, the \A syntax won’t work correctly if you are using a Notepad++ older than v7.9.1, so make sure you have a recent Notepad++. v7.9.1 was the last to have auto-update triggered, so if you’ve checked for updates, you should be on at least v7.9.1. I did confirm that v7.9.1 works with my second regex

      1 Reply Last reply Reply Quote 1
      • guy038G
        guy038
        last edited by guy038

        Hi, @peterjones,

        I did some other tests and there’s definitively something strange with your first regex version. Like you, I got a positive result, just once and some subsequent tests did not find anything !!! Right now, I’m still unable to see the right point and I’m still investigating :-((


        Now, regarding your second version, sorry, but I’ve found out an issue when a correct line username •••• password •••• begins a line and is followed with some characters, as in the G8.txt file, below :

        usexrname admin pasxsword cisco
        username blah password blah 67890
        some other text
        

        With your second regex version (?i-s)\A(^(?!username \S+ password \S+).*$\R*)+\z, the G8.txt file is not listed in the Search results panel, as it should be !

        If I slightly change your regex as (?i-s)\A(^(?!username \S+ password \S+$).*\R?)+\z, this time, the G8.txt file is correctly part of the list

        As you can see, I put a $ assertion at the end of the negative look-ahead, deleted this same assertion previously located before \R*, which I also modified as \R? as any line has EOL chars, only once or possibly not in case of the last line of the file !

        The path is difficult but we will get there !

        Best Regards

        guy038

        PeterJonesP 1 Reply Last reply Reply Quote 1
        • PeterJonesP
          PeterJones @guy038
          last edited by

          @guy038 said in sample config:

          As you can see, I put a $ assertion at the end of the negative look-ahead,

          Yes, that definitely makes more sense, from the logical/algorithmic standpoint. @Justin-Lang should use that variant if using my “family” of regex at all. Of course, this all assumes that the original assumptions I made, based on just one piece of example text, is sufficient to thoroughly describe the exact rules. The OP has never confirmed whether spaces are allowed before or after, or whether it should match or not match in the weird situations like text before and/or after on the same line, or not. So at this point, I think I’ve done enough for this question from the OP.

          1 Reply Last reply Reply Quote 0
          • Justin LangJ
            Justin Lang @PeterJones
            last edited by

            @PeterJones thank you so much for providing well explainnation of the regex. I am learning how to use it to match pattern in the network configuration files. Regex is very interesting and useful to quickly find matches in the file but very confusion too. Thanks for your help. I will continue to rely on your help as I am learning regex if you don’t mind.

            1 Reply Last reply Reply Quote 0
            • Justin LangJ
              Justin Lang @PeterJones
              last edited by

              @PeterJones thank you for your advice. I will continue try and learn regex. There is some regex tester online, but each of them support its own flavor of regex. Do you know which regex online tester that support .NET regex ? thanks

              PeterJonesP 1 Reply Last reply Reply Quote 0
              • PeterJonesP
                PeterJones @Justin Lang
                last edited by

                @Justin-Lang ,

                which regex online tester that support .NET regex ?

                The Regular Expression FAQ has links to external regex testers. One or more of them may support .NET regex, but I don’t know off the top of my head. Notepad++ uses the Boost regex engine (which is a variant of PCRE), not .NET regex. Since this forum is focused on discussing Notepad++, not supporting and answering questions on all flavors of regex, so if you have .NET regex specific questions, here is not the right place for them.

                1 Reply Last reply Reply Quote 0
                • Justin LangJ
                  Justin Lang @guy038
                  last edited by

                  @guy038 thanks so much.

                  1 Reply Last reply Reply Quote 1
                  • guy038G
                    guy038
                    last edited by guy038

                    Hello, @peterjones, @justin-lang, @alan-kilborn and All,

                    To @peterjones only :

                    Let’s back to your first regex version (?i-s)\A(^.*\R(?!^username \S+ password \S+$))+\z. This regex look for a continuous range of lines, not followed with an entire line username •••• password ••••, between the very beginning and the very end of current file. In this case a match occurs and this file is displayed in the Search results window

                    But, if so, in order to match the \z assertion, as the last line of current file may not end with EOL chars, this first version should be (?i-s)\A(^.*\R?(?!^username \S+ password \S+$))+\z with a question mark ? after \R ?

                    And, indeed, this first modified version does work on my machine, with the additional results already known when the username •••• password •••• is the first line of current file

                    Well, end of the story regarding this bugged version, anyway !!


                    To All :

                    I improved my own version to :

                    SEARCH \A(?s)(?:.*?(?i)^username \S+ password \S+$(*SKIP)(*F)|)

                    As you can see :

                    • The regex now uses a non-capturing group ( could be interesting if file of big size or with long lines ! )

                    • It searches for the smallest range of chars till a entire line username •••• password ••••

                    • In case of no line username •••• password •••• exists, in current file, the second empty alternative simply searches the \A position, which is the very beginning location of current scanned file !


                    Now, here is an off-topic subject :

                    When doing all my tests, I wanted to keep the “Find in Files” dialog opened, after each click on the Find All button ! So, I changed, in the <FindHistory •••••••• > section of the config.xml file, the value of the dlgAlwaysVisible attribute from no to yes

                    However, after re-starting N++, no luck : the “Find in Files” dialog was still closed after running a search :-(( I verified that this wrong behavior occurs since the v7.9.0 release !

                    Could you confirm me that fact, with the new Non-XP releases ? In case of positive answer(s), I will create an issue, on GitHub !

                    Best Regards,

                    guy038

                    Alan KilbornA 1 Reply Last reply Reply Quote 0
                    • Alan KilbornA
                      Alan Kilborn @guy038
                      last edited by Alan Kilborn

                      @guy038

                      When doing all my tests, I wanted to keep the “Find in Files” dialog opened, after each click on the Find All button ! So, I changed, in the <FindHistory •••••••• > section of the config.xml file, the value of the dlgAlwaysVisible attribute from no to yes

                      Maybe what you are trying to do manually is conflicting with this setting?:

                      2987c38a-5e94-4097-a8f9-d18f0d69695c-image.png

                      EDIT: I have no idea why my screenshot is twice as big vertically as intended! :-)

                      1 Reply Last reply Reply Quote 2
                      • guy038G
                        guy038
                        last edited by guy038

                        Hi, @alan-kilborn and All,

                        How silly am I !! I did not notice that this old setting has been adding in the Preferences dialog. Nice ! So , no need to create any issue : good ;-)) This also explains why this pseudo-issue begins with the v7.9.0 issue !

                        After ticking this option, in the Preferences dialog and closing N++, the value of the dlgAlwaysVisible attribute is still no in the config.xml file !

                        Cheers,

                        guy038

                        Alan KilbornA 1 Reply Last reply Reply Quote 2
                        • Alan KilbornA
                          Alan Kilborn @guy038
                          last edited by Alan Kilborn

                          @guy038 said in sample config:

                          After ticking this option, in the Preferences dialog and closing N++, the value of the dlgAlwaysVisible attribute is still no in the config.xml file !

                          Hmm. I would think that dlgAlwaysVisible would get erased from the FindHistory section at the N++ release that moves control to the Searching section of config.xml; example of that:

                          <GUIConfig name="Searching" monospacedFontFindDlg="yes" stopFillingFindField="no" findDlgAlwaysVisible="yes" confirmReplaceInAllOpenDocs="yes" />
                          

                          Notice the name is now slightly different, too: findDlgAlwaysVisible

                          But…I really don’t know how such “obsolete” items are handled.

                          So , no need to create any issue

                          If obsolete settings are supposed to be removed, maybe THAT’S an issue you could open!

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