• Login
Community
  • Login

How can I search a specific numbers in between two numbers?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 3 Posters 2.1k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R
    RAB_ROAD
    last edited by Dec 29, 2021, 3:10 AM

    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!

    T 1 Reply Last reply Dec 29, 2021, 4:04 AM Reply Quote 0
    • T
      Terry R @RAB_ROAD
      last edited by Dec 29, 2021, 4:04 AM

      @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 following

      If 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

      R 2 Replies Last reply Dec 29, 2021, 4:39 AM Reply Quote 3
      • R
        RAB_ROAD @Terry R
        last edited by Dec 29, 2021, 4:39 AM

        @terry-r wow you are the best very thanks you man

        1 Reply Last reply Reply Quote 0
        • R
          RAB_ROAD @Terry R
          last edited by Dec 29, 2021, 12:19 PM

          @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 following

          If 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

          A 1 Reply Last reply Dec 29, 2021, 12:28 PM Reply Quote 0
          • A
            Alan Kilborn @RAB_ROAD
            last edited by Dec 29, 2021, 12:28 PM

            @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)

            1 Reply Last reply Reply Quote 1
            • A Alan Kilborn referenced this topic on Dec 29, 2021, 12:37 PM
            1 out of 5
            • First post
              1/5
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors