• Login
Community
  • Login

Searching a file for numbers with a specific number of digits.

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
6 Posts 5 Posters 1.3k 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.
  • J
    Jonathan Jones
    last edited by Jan 8, 2021, 8:02 PM

    I’m looking to find a way to search a file for a specific string, follow by specific number of wildcard digits. I have tried \d but I don’t believe I am using it for its intended purpose. I would ideally do this using the Find functionality.

    Example: “Serial Number: #####”

    A 1 Reply Last reply Jan 8, 2021, 8:14 PM Reply Quote 0
    • A
      Alan Kilborn @Jonathan Jones
      last edited by Alan Kilborn Jan 8, 2021, 8:15 PM Jan 8, 2021, 8:14 PM

      @Jonathan-Jones

      Serial Number: \d{5} would search for 5 digits. You’d want to set your search mode to regular expression.

      If you want exactly 5, and not 6, you might want to change it to Serial Number: \d{5}(?!\d) which means 5 digits followed by something that is not a digit.

      J L 2 Replies Last reply Jan 8, 2021, 8:24 PM Reply Quote 3
      • J
        Jonathan Jones @Alan Kilborn
        last edited by Jan 8, 2021, 8:24 PM

        @Alan-Kilborn said in Searching a file for numbers with a specific number of digits.:

        \d{5}(?!\d)

        Thank you! The combination of string followed by \d{5}(?!\d) gave me exactly what I wanted!

        1 Reply Last reply Reply Quote 1
        • L
          logi tech @Alan Kilborn
          last edited by Jul 31, 2024, 4:29 AM

          @Alan-Kilborn

          What If I wanted to search for a specific number for example : 3XXXXX5849
          XXX are digit numbers
          thanks for help in advance.

          G M 2 Replies Last reply Jul 31, 2024, 6:25 AM Reply Quote -1
          • G
            gerdb42 @logi tech
            last edited by Jul 31, 2024, 6:25 AM

            @logi-tech

            Well, then search for 3\d{5}5849. This regex isn’t much of rocket science, just have a look at https://community.notepad-plus-plus.org/topic/15765/faq-where-to-find-regular-expressions-regex-documentation

            1 Reply Last reply Reply Quote 0
            • M
              Mark Olson @logi tech
              last edited by Jul 31, 2024, 3:30 PM

              logi-tech said:

              What If I wanted to search for a specific number for example : 3XXXXX5849

              This user has asked the same question three times in three different threads. At this point, I’m pretty sure they’re a bot fishing for upvotes.

              We should stop dignifying them with replies until they prove they’re human.

              1 Reply Last reply Reply Quote 2
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors