I have long lines containing patterns I wish to extract. The pattern I wish to extract is 16 numeric digits, followed by whitespace, followed by 4 digit month-year (MM/YY), followed by whitespace, followed by 3 numeric digits.
I'm able to find the strings of interest with this regex:
(([0-9]{15,})\w+)|(\d{1,2}[/]\d{1,2})|(\s[0-9]{3}\s)
I found a similar question about 'Inverse Replace' in NPP with Regex, but the solution there, which is to use !
or ^
to do a find and replace on everything else doesn't seem to work in this case, perhaps because more than 1 pattern is involved in my search and/or due to the use of |
.
It was also on the line-level. I also don't want to extract entire lines by marking them then doing line-level operations, because there's lots of extra garbage before and after the target strings on the same lines.
Sample text:
slfkmsdfklms sdflmds sdlfksdf 0000000000000000 01/01 222 lkm22s2d?f slkfdmf02324l/kj slfkmsdfklms sdflmds sdlfksdf 1000000000000000 01/01 222 lkm22s2d?f slkfdmf02324l/kj slfkmsdfklms sdflmds sdlfksdf 2000000000000000 01/01 222 lkm22s2d?f slkfdmf02324l/kj slfkmsdfklms sdflmds sdlfksdf 3000000000000000 01/01 222 lkm22s2d?f slkfdmf02324l/kj
Desired result:
0000000000000000 01/01 222 1000000000000000 01/01 222 2000000000000000 01/01 222 3000000000000000 01/01 222
Alternate (more realistic, less clean) sample text:
414720 [SOUTH METRO] RECORD_NUMBER SIGNATURE 1142202351790900 02/22 997 NAME J BOONE [United States] , Doctor , Radio , 01157 Example PLATE DATABASE USA, N.A.; loud speaker 0523_US 7.60 VALID [T] 466245 [SOUTH METRO] RECORD_NUMBER RUBY 1662451125354000 09/21 064 DUDE LI [United States] , Doctor , Columbia , 210AA Example N/A; loud speaker 0523_US 7.60 VALID [T] 1891-05-25 01:34 Order #1590359692 (view full information -> txt, csv, short)
438857 [SOUTH METRO] RECORD_NUMBER SIGNATURE 1388576129333547 02/24 812 LAURA SOMETHING [United States] , MA , Boston , 0BB130 Example Phone Email DOB PLATE DATABASE USA, N.A.; loud speaker 0523_US_IP 23.25 VALID [T] 1891-05-25 00:08 Order #1590354533 (view full information -> txt, csv, short)
414734 [SOUTH METRO] RECORD_NUMBER SIGNATURE 1147342081333000 05/23 178 SHEILA TESTEST [United States] , iPhone , Native , 08020 Example Phone Email DOB FIA CARD SERVICES, N.A.; loud speaker 0524_US_IP 23.75 VALID [T] 1891-05-21 23:23 Order #1590092597 (view full information -> txt, csv, short)
414740 [SOUTH METRO] RECORD_NUMBER SIGNATURE 0000400204940000 11/22 270 AUSTIN WORDS [United States] , Doctor , Atlantis , 21157 Example PLATE DATABASE USA, N.A. 0521_US 7.60 VALID [T] 414709 [V