hi all, don't be scared, the video is about 1mb
the video displays using the replace window, with a regex for matching and a dummy text for replacement
i press the "replace" button but it doesn't replace anything, instead it just selects the next text match
on the other hand when i press the "replace all" button, all the text parts matching the regex do get replaced as intended
so that's the problem, what the $^&% am i doing wrong and the "replace" button is not working as expected?
right click on the file, download it and open with a video player (it's not an image, i've just renamed it to jpg)
thnx a lot
This behaviour is really strange, but we can't do anything about it :((
Indeed, if your regex contains lookbekinds or the \K form, a clic on the Replace button doesn't produce any replacement at all !
Consider the simple text : Menu 1, Menu 2, Menu 3
Then the search of (?<=m)e ( or the similar search m\Ke ) and the replacement by the uppercase letter E, ONLY works if you click on the Replace All button !!! and produces the text : MEnu 1, MEnu 2, MEnu 3.
One valuable trick : if your replacement concerns the second part of your file, whatever its size, go to the beginning of that second part, UNSET the Wrap around square box and with a click on the Replace All button, the changes are made from that point to the end of your file only !
Notice that if you use the regular expression e(?=n), with a lookahead, instead, a clic on the Replace button does change the lowercase letter E into the uppercase letter E, step by step ! It produces the same text : MEnu 1, MEnu 2, MEnu 3.
yeah i see, thnx a lot for the response
you have to understand that i've had huge problems with the simplest of projects
it's common with computers but on this one, god.. on every step i got impossible bugs in various programs and even hardware problems (the gpu got fried out of the blue ffs..) and i've been wasted more than a week for something that should be completed in hours max
the real document is like a billion lines long and the replacement text is also a regex so even though i knew np++ has bugs my mind went straight to the thought that the replacement regex was the problem and i wasted another two days just on trying to fix it before i realized that wasn't the problem
so while i was near shooting my brains out, i decided i'd take every little problem i've had with this problem, on video, post it on the official support forums of each software titles and fight it like a boss you know and most of all to see i haven't gone crazy yet and these bugs are real and really paranoid..
thnx again for your time
To be quite exact about your problem, the replacement, step by step, doesn't work if your regex contains, ONLY, a positive lookbehind or the \K form.
BUT, if your regex contains a negative lookbehind or a lookahead, positive or negative, the step by step replacement works fine ! Very strange, isn't it !!!
Let consider the sentence just above. Then, the different searches :
(?<![nv])e or e(?=[gp]) or e(?![gp]), and replacement by the uppercase letter E, don't disturb the step by step replacement at all :-)
BTW, conditional replacements, allowed by the PCRE engine of N++, in regex mode, are really interesting :-))
Two examples :
SEARCH : (John)|(dog)|(brown)
REPLACE : (?3black and white)(?2cat)(?1Mary)
(?3black and white)(?2cat)(?1Mary)
=> Then, the sentence "The dog of John is brown" becomes "The cat of Mary is black and white" !!
John = group 1, dog = group 2 and brown represents the group 3
The form (?n....) is the replacement part of the group n matched
Let, now, consider the list, below, of names and ages, at the beginning of each line :
Then the S/R below :
REPLACE (?1Age :Name) : $&
(?1Age :Name) : $&
transforms, automatically, that list into :
Name : Peter
Age : 26
Name : Jack
Age : 15
Name : Mary
Age : 27
Name : Chris
Age : 40
If the line contains some digits, then the OPTIONAL group 1 (\d+)? is quite defined. So the THEN part of the conditional replacement ( before the colon ), the string "Age : " is inserted, before the entire search string $& ( the age )
If the line doesn't contain digits, then the OPTIONAL group 1 is NOT defined, and characters are matched with the .+ form. So the ELSE part of the conditional replacement ( after the colon), that is to say, the string "Name : " is inserted, before the entire search string $& ( the name )
Hope this will be useful to you, somehow !!
You will find good documentation, about the new Perl Common Regular Expressions (PCRE), used by N++, since the 6.0 version, at the TWO addresses below :
The FIRST link concerns the syntax of regular expressions in SEARCH
The SECOND link concerns the syntax of regular expressions in REPLACEMENT
thnx very much for your time and help, it is helpful, the second example and method saved me from a lot of research
i know how powerful regex is, and that's why im studying it, it's just that im still on my first steps with regex and im not a programmer or something so even when im reading the reference or a guide, i don't always understand everything yet