sample config
-
@guy038 said in sample config:
Could it be related to enhancements in Npp v7.9.3 or v7.9.4 releases
I am getting strange results. The first time I tried in v7.9.2, it didn’t work, and I thought I confirmed that 7.9.2 and 7.9.3 didn’t work. But then I went back to v7.9.2 and tried my new one followed by my old one, and now it seems that the old regex is working in v7.9.2:
It’s not truly important. The fixed regex works consistently for me and for you.
-
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 -
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 theG8.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
, theG8.txt
file is not listed in theSearch results
panel, as it should be !If I slightly change your regex as
(?i-s)\A(^(?!username \S+ password \S+$).*\R?)+\z
, this time, theG8.txt
file is correctly part of the listAs 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
-
@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.
-
@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.
-
@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
-
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.
-
@guy038 thanks so much.
-
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 lineusername •••• password ••••
, between the very beginning and the very end of current file. In this case a match occurs and this file is displayed in theSearch results
windowBut, 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 fileWell, 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 theconfig.xml
file, the value of thedlgAlwaysVisible
attribute fromno
toyes
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
-
-
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?:
EDIT: I have no idea why my screenshot is twice as big vertically as intended! :-)
-
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 thev7.9.0
issue !After ticking this option, in the
Preferences
dialog and closing N++, the value of thedlgAlwaysVisible
attribute is stillno
in theconfig.xml
file !Cheers,
guy038
-
@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 theFindHistory
section at the N++ release that moves control to theSearching
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!