Reputation: 2101
I have a text file that has unix epoch timestamps mixed in with a lot of scrambled text. So, I need to check for 10 digit numbers, starting and ending with non-numeric characters.
I tried:
[:alpha:]([0-9]{10})[:alpha:]
but it doesn't work.
Upvotes: 1
Views: 2002
Reputation: 7616
I just tested this text with notepad++:
aaa1234567890bbb
11.1234567890@99
too short:123456789
(?<=\D)(\d{10})(?=\D)
Explanation:
(?<=\D)
- positive lookbehind for a non-digit char (no capture)(\d{10})
- capture 10 digits(?=\D)
- positive lookahead for a non-digit char (no capture)Upvotes: 1
Reputation: 4564
Maybe the POSIX [:alpha:] doesn't work with Notepad++
[:alpha:]
equals [a-zA-Z]
and in your case may also be substituted by \D
(equals One non-digit)
Have you tried one of these:
(fist will select 10 digits including 2 extra characters at start/end
others with lookahead/lookbehind just select the exact 10 digits)
\D([0-9]{10})\D
(?<=\D)([0-9]{10})(?=\D)
positive lookahead/lookbehind(?<!\d)([0-9]{10})(?!\d)
negative lookahead/lookbehindUpvotes: 1