How can I search a specific numbers in between two numbers?
-
Hey,
I’m new on notepad++, and I want to know how can I lookup for a numbers in between two number:Like I want to search in a text file full of numbers and words, and I only want to find the numbers between 250-500, so all the numbers from 250-500 will be in search, in others words, no numbers should be search but only the number between 250-500!
-
@rab_road said in How can I search a specific numbers in between two numbers?:
Like I want to search in a text file full of numbers and words, and I only want to find the numbers between 250-500, so all the numbers from 250-500 will be in search, in others words, no numbers should be search but only the number between 250-500!
You could try the following regular expression. Depending on what you want to do you might use the Mark function so that you can bookmark the lines containing the numbers you are looking for, tick bookmark lines and then use the F2/Shift-F2 to jump between the numbers.
Also the Mark function can highlight the numbers you want, then you can use the Copy Marked Text, open a new tab and paste them (Ctrl-V).
Find What
(?<!\d)(2[5-9]\d|(3|4)\d\d|500)(?!\d)
What it does is:
(?<!\d) - at the cursor position the previous character is NOT a digit
(2[5-9]\d|(3|4)\d\d|500)(?!\d) - the|
character denotes alternation, thus there is the option to take any one of 3 possible steps
2[5-9]\d - the number starts with 2, then must be either a 5,6,7,8 or 9. The third digit can be anything
(3|4)\d\d - the number can start with either a 3 or a 4, then the next 2 digits can be anything
500 - the number must be exactly 500
(?!\d) - there cannot be any digit followingIf you were to more fully explain what you intend doing with these numbers there might be a better solution, but the above regular expression will locate those numbers and nothing else.
If you post examples or more information please read the Read Me. This is pinned at the start of this group so new comers can read before asking.
Terry
-
@terry-r wow you are the best very thanks you man
-
@terry-r said in How can I search a specific numbers in between two numbers?:
@rab_road said in How can I search a specific numbers in between two numbers?:
Like I want to search in a text file full of numbers and words, and I only want to find the numbers between 250-500, so all the numbers from 250-500 will be in search, in others words, no numbers should be search but only the number between 250-500!
You could try the following regular expression. Depending on what you want to do you might use the Mark function so that you can bookmark the lines containing the numbers you are looking for, tick bookmark lines and then use the F2/Shift-F2 to jump between the numbers.
Also the Mark function can highlight the numbers you want, then you can use the Copy Marked Text, open a new tab and paste them (Ctrl-V).
Find What
(?<!\d)(2[5-9]\d|(3|4)\d\d|500)(?!\d)
What it does is:
(?<!\d) - at the cursor position the previous character is NOT a digit
(2[5-9]\d|(3|4)\d\d|500)(?!\d) - the|
character denotes alternation, thus there is the option to take any one of 3 possible steps
2[5-9]\d - the number starts with 2, then must be either a 5,6,7,8 or 9. The third digit can be anything
(3|4)\d\d - the number can start with either a 3 or a 4, then the next 2 digits can be anything
500 - the number must be exactly 500
(?!\d) - there cannot be any digit followingIf you were to more fully explain what you intend doing with these numbers there might be a better solution, but the above regular expression will locate those numbers and nothing else.
If you post examples or more information please read the Read Me. This is pinned at the start of this group so new comers can read before asking.
Terry
How i can search beetween 4 digits number ? Exemple beetween 1000 and 1500
-
@rab_road said in How can I search a specific numbers in between two numbers?:
…between 1000 and 1500
inclusion of the endpoints is implied? :-)
(?<!\d)(?:(?:1[0-4]\d\d)|(?:1500))(?!\d)
-