Looking for some help with regex. I've a text document that I need to extract some information out of, while discarding the rest. It's made more difficult by the fact that data is line wrapped. What I need is any instance of six digits (numbers) in a row. All instances of this are also surrounded by single quotes if that helps. Snippet of the data pasted below:
** Error [ 202 ] ** þRecord '251374' is not on fileþ ** Error [ 202 ] ** þRecor
d '251375' is not on fileþ ** Error [ 202 ] ** þRecord '227430' is not on fileþ
** Error [ 202 ] ** þRecord '227433' is not on fileþ ** Error [ 202 ] ** þRecord
'251473' is not on fileþ ** Error [ 202 ] ** þRecord '251474' is not on fileþ *
* Error [ 202 ] ** þRecord '251477' is not on fileþ ** Error [ 202 ] ** þRecord
'251478' is not on fileþ ** Error [ 202 ] ** þRecord '251480' is not on fileþ **
Error [ 202 ] ** þRecord '251482' is not on fileþ ** Error [ 202 ] ** þRecord '
171543' is not on fileþ ** Error [ 202 ] ** þRecord '171544' is not on fileþ **
Error [ 202 ] ** þRecord '171545' is not on fileþ ** Error [ 202 ] ** þRecord '1
71546' is not on fileþ ** Error [ 202 ] ** þRecord '171547' is not on fileþ ** E
rror [ 202 ] ** þRecord '171548' is not on fileþ ** Error [ 202 ] ** þRecord '17
1549' is not on fileþ ** Error [ 202 ] ** þRecord '171550' is not on fileþ ** Er
ror [ 202 ] ** þRecord '171551' is not on fileþ ** Error [ 202 ] ** þRecord '171
552' is not on fileþ ** Error [ 202 ] ** þRecord '171553' is not on fileþ ** Err
or [ 202 ] ** þRecord '171554' is not on fileþ ** Error [ 202 ] ** þRecord '1715
55' is not on fileþ ** Error [ 202 ] ** þRecord '131551' is not on fileþ ** Erro
r [ 202 ] ** þRecord '171556' is not on fileþ ** Error [ 202 ] ** þRecord '26758
8' is not on fileþ ** Error [ 202 ] ** þRecord '123584' is not on fileþ ** Error
[ 202 ] ** þRecord '251645' is not on fileþ ** Error [ 202 ] ** þRecord '227655
' is not on fileþ ** Error [ 202 ] ** þRecord '219724' is not on fileþ ** Error
[ 202 ] ** þRecord '219725' is not on fileþ ** Error [ 202 ] ** þRecord '219726'
is not on fileþ ** Error [ 202 ] ** þRecord '219727' is not on fileþ ** Error [
202 ] ** þRecord '267738' is not on fileþ ** Error [ 202 ] ** þRecord '131725'
is not on fileþ ** Error [ 202 ] ** þRecord '131748' is not on fileþ ** Error [
202 ] ** þRecord '131755' is not on fileþ ** Error [ 202 ] ** þRecord '235796' i
s not on fileþ ** Error [ 202 ] ** þRecord '195865' is not on fileþ ** Error [ 2
02 ] ** þRecord '195866' is not on fileþ ** Error [ 202 ] ** þRecord '195867' is
not on fileþ ** Error [ 202 ] ** þRecord '195868' is not on fileþ ** Error [ 20
2 ] ** þRecord '195869' is not on fileþ ** Error [ 202 ] ** þRecord '195870' is
not on fileþ ** Error [ 202 ] ** þRecord '195871' is not on fileþ ** Error [ 202
] ** þRecord '195872' is not on fileþ ** Error [ 202 ] ** þRecord '195873' is n
ot on fileþ ** Error [ 202 ] ** þRecord '195874' is not on fileþ ** Error [ 202
] ** þRecord '195875' is not on fileþ ** Error [ 202 ] ** þRecord '195876' is no
t on fileþ ** Error [ 202 ] ** þRecord '195877' is not on fileþ ** Error [ 202 ]
** þRecord '195878' is not on fileþ ** Error [ 202 ] ** þRecord '195879' is not
on fileþ ** Error [ 202 ] ** þRecord '259887' is not on fileþ ** Error [ 202 ]
TextPad regex to clean up document
Moderators: AmigoJack, bbadmin, helios, MudGuard
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
Here is a three step solution. (Could make into a macro and assign a hot key to do with one key....)
Step 1 ( prepare to make consistent lines.)
Search for: \n
Replace with: nothing
Step 2 (make consistent lines)
Search for: \*\* Error
Replace with: \n** Error
Step 3 (extract the six digits)
Search for .*([0-9]{6}).*
Replace with: \1
Use the following settings:
-----------------------------------------
[X] Regular expression
Replace All
-----------------------------------------
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
-----------------------------------------
Step 1 ( prepare to make consistent lines.)
Search for: \n
Replace with: nothing
Step 2 (make consistent lines)
Search for: \*\* Error
Replace with: \n** Error
Step 3 (extract the six digits)
Search for .*([0-9]{6}).*
Replace with: \1
Use the following settings:
-----------------------------------------
[X] Regular expression
Replace All
-----------------------------------------
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
-----------------------------------------
Hope this was helpful.............good luck,
Bob
Bob