How to replace a specific text in lines that contains a specific word.
-
@guy038 said in How to replace a specific text in lines that contains a specific word.:
I may be wrong but I think that the correct search expression
I think the original is solution is fine.
Perhaps the?=
in it is confusing (looks maybe like a(?=
…)
construct?)
But really it just forces=false
to be matched. -
Hi, @zsombor-szarka, @alan-kilborn, @peterjones and All,
My bad ! Alan, I didn’t notice the equal sign in your version :-(
BR
guy038
-
Not a problem, Guy.
Like I said maybe I shouldn’t have done it the way I did, because it really does look like that other construct.BTW, good to see you posting.
You haven’t been very active lately.
Hopefully you are “back” and will be posting on a more regular basis now. -
No it worked perfectly, not almost.
Just because you left something out of your problem statement doesn’t mean the solution provided was deficient. :-)Well i can’t argue with that, i should have formulated my sentences better.
Anyway now it works as i wanted to, so thanks a lot!Have a wonderful day!
-
I started to learn about the search mechanism of notepad++, but it’s way too complex for me to figure it out. (i spent an hour learning it so far)
Well, any time invested in this endeavor is time well spent (for the NEXT time).
Can you give … explain it too?
I basically gave the syntax:
(?-s)ingot.*?=\Kfalse
It means:
(?-s)
: don’t let a following.
match a line-ending
ingot
: match the literal text
.*?
: match any characters zero or more times, minimally
=
: match literal equal
\K
: forget the match to this point (we don’t want to changeingot
followed by whatever followed by=
)
false
: match the literal textWe replace with only
true
because the matched text will befalse
at this point. -
@alan-kilborn
Thanks a lot (again)!
I understand everything except this line:(?-s)
: don’t let a following.
match a line-endingI can’t figure out what do you mean by that… Can you elaborate?
-
@zsombor-szarka said in How to replace a specific text in lines that contains a specific word.:
I understand everything except this
You even understand the
\K
fully? :-)Ok so the
(?-s)
is equivalent to leaving this checkbox unchecked:But what it means is that using a
.
further along in the expression will NOT match a line-ending character.When you originally said:
is to replace all the “=false” texts to “=true” in lines
The “in lines” part is a real key that
(?-s)
should be used.Otherwise, you could get a match like this (definitely unwanted):
Note that I changed your data a bit in the above.
See how there is a match on line 10 even though there is no
ingot
on line 10? The ingot part starts on line 9… :Note that what I’m showing now is if you use
(?s)
instead of(?-s)
. The-
turns off the ability to match line ending characters.So the
(?-s)
is a safety-valve on the expression, in this instance saying “everything must be on the same line”.Hopefully that makes a bit of sense.
-
@alan-kilborn said in How to replace a specific text in lines that contains a specific word.:
So the (?-s) is a safety-valve on the expression, in this instance saying “everything must be on the same line”.
This sentence sums it up clearly, after this one i was sure i understood everything what you just wrote.
I don’t know why did you ask whether i understood the \k fully, but i did.
In fact everything was simple, what probably confused me, is that i did not catch what did you mean by “following .” i had no idea that by the dot you meant the whole search.Now everything is clear and i even have a greater understanding on some of the things, i read on the notepad++ wiki.
Thanks!BS
-
You said :
You haven’t been very active lately.
You’re quite right ! Well, there’s a simple explanation to this :
-
First of all, at this time of the year, I am rather involved in ski, which is a passion of mine !
-
Secondly, each Wednesday, with eight other people, we supervise , at the
Chamrousse
station,( the nearest from Grenoble )50
children about, from 5 to 14 years old, in ski lessons, for any level, fromDébutants
toFlèche de Bronze
( approximatively, from american ski level1
to8
: refer, for instance, https://www.tripsavvy.com/skiing-ability-levels-3007976 ) -
And thirdly, last week-end, we were 13 people at Courchevel, a very well-known French station, with a wonderful sunny and blue weather ! Really, we had lunch, Sunday midday, on the terrace of the hotel and it was rather hot, at about
1700 m
!
Next Thursday, we’ll be, for the day, at the Karellis station :
Best regards,
guy038
-
-
@guy038 said in How to replace a specific text in lines that contains a specific word.:
First of all, at this time of the year, I am rather involved in ski, which is a passion of mine !
I’m not an excellent skier, but nothing sounds better to me right now than joining you on those slopes! :-)
-