Searching a file for numbers with a specific number of digits.
-
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: #####”
-
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. -
@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!