Search positive + egative (in-/exclude)
-
Hi there,
i got a number of configuration files that always come with identical commands lines but different values to it.For example, it always has the paramter ‘notification_days_ahead’ - I need to ensure it always gets a certain value (e.g. 5) set to it but only if it it reads any other value than 5.
The line replacement I already figured out but the selective selection not quite …
May be a simple selection term but I dont get it.
Thanks a good hint!
Uwe -
Your data is incomplete, so your question can’t be answered with certainty. Please see FAQ for how to ask such questions properly.
However, let’s assume your data looks like this:
notification_days_ahead=27
. In this case, you would:Find:
notification_days_ahead=\d+
Replace:notification_days_ahead=5
Search mode: Regular expressionIt doesn’t really matter if your data is already 5, because what I’ve given you would just replace that with 5 anyway.
-
@Alan-Kilborn
Hi Alan, Thanks for looking into this!
Actually, the FAQ etc - I felt overwhelmed + lost surely due to my missing background…In the files the command line in question looks like this
Bei_Kontraktverfall_warnen_Tage=4Since I am keen on touching only those files where the value in this line is not 4, I think I need to have the positive FIND (of the line in general) and then added the exclusion (‘where value is not 4’).
Does that explain the matter a bit more?Thanks!
-
@Uwe-Recknagel said in Search positive + egative (in-/exclude):
I am keen on touching only those files where the value in this line is not 4
Does that explain the matter a bit more?I thought it was 5, not 4, but…no matter.
If the concern is about touching files, we can restrict it to non-5 (I’m sticking with 5) data.
-
Find:
notification_days_ahead=(?!5\D)\d+
-
@Alan-Kilborn
Hey Alan, Thanks a lot, that tackles this one quite nicely!Looking further into the file other parameters it apparently doesn’t catch this way - e.g.
fixed_Lot=0.10000000 or fixed_Lot=0.1 (or a variable number of zeros) - I need to check for a value = -1 (to deactivate te paramter).
Replacing in your statement the number 4 by -1 doesnt return a beneficial result. May it be due to -1 is recognised as a different format than 4?Thanks again for strechting your time!
Uwe -
Well, you see, you keep growing the “spec” for what you need. You get a couple of freebies from us here (because really we just want regular-expression questioners to “go away quickly” – we’re more interested in really Notepad++ specific discussions).
After your freebies are exhausted, or sometimes even before, we advise you to read FAQ about regular expressions, found HERE, so you can “roll your own”. You gain powerful knowledge, we get back to better Notepad++ topics. Win/win. :-)
-
@Alan-Kilborn
alright, I see. the FAQ I read in parallel, trying to understand+translate your input.
Thanks! -
As an additional hint, the information found HERE seems directly applicable to an aspect of the problem you are trying to solve.