near89
near89

Reputation: 31

regex certain character notepad++

Let me get this short. I have this document:

=================================

Dealer PIN 57FG2119 Malaysia. ID [2DF88565] Filiphine. BBM  : 5B7AF062
LINE  :agungpra.
No hp:082187754243
Open agen, reseller & dropship
CS 1 : PIN 5353ABC2
CS 2 : SMS 085711439997
Fb : Griya Madinah
Fanpage : Madinah butik
Email : [email protected]
Dermastore Group
Stokis VVIP Indonesia 100% Original
Pemesanan/konsultasi:
5A66BC4D (BBM) 081320232353 (SMS) 08114530052 (WA) @dermastorecoid (LINE)
*Viciadas em Moda, Maquiagem, Unhas Comprinhas, Viagens*ABC-SP
[email protected]

================================

As we see. There's some pin BB. 8 pin BB characters. I'm looking for a REGEX formula which be able to sort/save/block/keep all 8 characters and delete the rest. So the final result will be like this. Pin BB only. 8 characters only (with automatically have the enter or space of each line)

57FG2119 
2DF88565
5B7AF062
5353ABC2
5A66BC4D 

I'm really blank on it. Really I need a help. Thank you.

Upvotes: 1

Views: 389

Answers (2)

Jason C
Jason C

Reputation: 40325

You actually can do this in a single regex.

In Notepad++'s find-replace:

enter image description here

This basically says "match a pin; if there are more pins after it leave them for the next match otherwise just consume the rest of the junk (i.e. tail of file after last pin)".

The regex .*?\b([0-9A-Z]{8})\b|.* works as well, it is a bit simpler but will leave a blank line at the end (there the |.* at the end matches the last bit of the input if no more pins are found).

For more info check out Notepad++'s regex support.

In your sample input the output is:

57FG2119
2DF88565
5B7AF062
5353ABC2
5A66BC4D

Upvotes: 2

gzix
gzix

Reputation: 269

You cannot do that in a single regex..

Step 1: In Notepad++, press CTRL+H and check Search Mode 'Regular expression' below..

Step 2: Check 'Match case' and 'Wrap around'

Step 3: Fill 'Find what' box entry with

  \b([0-9A-Z]{8})\b

Step 4: Fill 'Replace with' entry with

  $1\n

Step 5: Click 'Replace All'

Step 6: Again fill 'Find what' box entry with

  [\w\W]*?\b([0-9A-Z]{8})\b

Step 7: And fill 'Replace with' box with

  $1\n

Step 8: Click 'Replace All'

Now you have your BB pins

enter image description here

Upvotes: 0

Related Questions