Extract the lines greater than
-
friends how can i select the lines that have movies greater than 14
user = 8732560 | domainId = 5674567 | points = 22.21 | N° movies = 13
user = 13567799 | domainId = 8879095 | points = 0.01 | N° movies = 1
user = 7688898 | domainId = 454679 | points = | N° movies = 24
user = 8743210 | domainId = 5633556 | points = 1 | N° movies = 17to
user = 7688898 | domainId = 454679 | points = | N° movies = 24
user = 8743210 | domainId = 5633556 | points = 1 | N° movies = 17 -
Hello @zarate-petery and All,
Easy with regular expressions !
As you don’t say anything about the upper limit of the
movies
numbers, I suppose that999
was the maximum !This leads to that regex S/R, with select all contents, including their line-breaks, of lines with a
movies
number greater than14
SEARCH
(?-s)^.+(?:[1-9]\d\d|1[5-9]|[2-9]\d)\R?
Notes : This regex is almost obvious ! A few points :
-
The
(?-s)
in-line modifier, at beginning of pattern ensures that the regex dot symbol represents a single standard character and not aline-break
character -
The
(?:....|.....|.....)
is the syntax of a non-capturing group of several alternatives-
The
1st
alternative looks for a three-digit number -
The
2nd
alternative looks for a two-digit number between15
and19
-
The
3rd
alternative looks for a two-digit number greater than19
-
-
The
\R?
represents any line-break character(s) of current scanned line. The?
quantifier, meaning{0,1}
have been added just in case that the last line does not have any line ending
Best regards
guy038
-
-
A couple of things:
-
When I try @guy038’s regex on the OP’s data, I get hits on all four lines. The OP wanted only the 3rd and 4th lines to be hit.
-
OP says “how can i select the lines?”. To that I say “What are you wanting to do with them?” Notepad++ currently contains no go way to select (as in “selected text”) data in this fashion, so if you want to copy only the data matching the criterion somewhere else, you have to turn to other mechanisms.
So back to the regex. I think it was @guy038’s desire to handle the “last line does not have any line ending” condition (probably a “late addition” to a finished solution?) that tripped up the regex. I’d suggest these variants, all of which seem to work:
(?-s)^.+(?:[1-9]\d\d|1[5-9]|[2-9]\d)\R
<— requires a line-ending on last line to match the last lineor
(?-s)^.+(?:[1-9]\d\d|1[5-9]|[2-9]\d)$\R?
<— adds a$
to anchor what comes before to line-endingor
(?-s)^.+(?:[1-9]\d\d|1[5-9]|[2-9]\d)(?:\R|\z)
<— use\z
for special end-of-file / last-line handling -
-
@Alan-Kilborn said in Extract the lines greater than:
Notepad++ currently contains no go way…
Ach. Was supposed to be “Notepad++ currently contains no good way…”
But @zarate-petery , if you really need a way to copy out the matched data, let us know, and we’ll provide one.
-
Hi, @zarate-petery and All,
Oh, My God ! I was totally wrong in many ways :-((
- Firstly @zarate-petery said :
user = 8732560 | domainId = 5674567 | points = 22.21 | N° movies = 13
user = 13567799 | domainId = 8879095 | points = 0.01 | N° movies = 1
user = 7688898 | domainId = 454679 | points = | N° movies = 24
user = 8743210 | domainId = 5633556 | points = 1 | N° movies = 17to
user = 7688898 | domainId = 454679 | points = | N° movies = 24
user = 8743210 | domainId = 5633556 | points = 1 | N° movies = 17And I thought that the OP wanted to select the entire lines with last number greater than
14
. Not at all ! May be, the OP just wants to delete lines with last number under15
!
- Secondly, I tested my search regex against the text, below, and, obviously, as it contains only one number per line, my regex wrongly worked nice !
Test 1 Test 2 Test 3 .... .... Test 149 Test 150
So, thanks to Alan, the right regex is one of his
3
solutions !However, I think it would be better to add the
\x20
syntax, right after the.+
part. Indeed, by default, the first part of the pattern^.+\x20
would match exactly what we want to ! No need for any backtracking ;-))For instance, the Alan’s
2nd
solution would be changed as(?-s)^.+\x20(?:[1-9]\d\d|1[5-9]|[2-9]\d)$\R?
Now, if the OP prefers that solution, here is a regex S/R, which deletes any line ending with a number smaller than
15
:SEARCH
(?-s)^.+\x20(?:1[0-4]|\d)$\R?
REPLACE
Leave EMPTY
Best Regards
guy038
-
@guy038 said in Extract the lines greater than:
And I thought that the OP wanted to select the entire lines with last number greater than 14.
Yes, you thought that because that’s what the OP said. :-)
May be, the OP just wants to delete lines with last number under 15 !
I don’t know about that.
I’ve already queried the OP on what his end goal is.
Probably best to wait for that answer, if it ever comes.