2

I have a text file with content similar to the following. I want to remove all text between Bank Applicants (the numeric strings) using the find-and-replace functionality of Notepad++.

0004829 01-02 000421
0004830 01-02 000422
0466608 06-47 000743
Bank sl. no beginning with an 'IA' indicates ICB account
Paramount Textile Limited Page No: 143 of 258
Lottery Conducted by--Dept. of Electrical and Electronic Engineering, BUET. Date:03/10/2013
General
Applicants
0004823 01-02 000415
0004824 01-02 000416
0004826 01-02 000418
0004829 01-02 000421
0004830 01-02 000422
0004831 01-02 000423
0004832 01-02 000424
Bank sl. no beginning with a
Lottery Conducted by--Dept. of Electrical and Electronic Engineering, BUET. Date:03/10/2013
General
Applicants
0004823 01-02 000415
0004829 01-02 000421
0004830 01-02 000422
0004831 01-02 000423
0004832 01-02 000424
0004839 01-02 000431
0004840 01-02 000432
Bank sl. no beginning with an 'IA' indicates ICB account
and Electronic Engineering, BUET. Date:03/10/2013
General
Applicants
0004823 01-02 000415
0004830 01-02 000422
0004831 01-02 000423
0004832 01-02 000424
0004839 01-02 000431

An example of the output I want is as follows:

0004829 01-02 000421
0004830 01-02 000422
0466608 06-47 000743
0004823 01-02 000415
0004824 01-02 000416
0004826 01-02 000418
0004829 01-02 000421
0004830 01-02 000422
0004831 01-02 000423
0004832 01-02 000424
0004823 01-02 000415
0004829 01-02 000421
0004830 01-02 000422
0004831 01-02 000423
0004832 01-02 000424
0004839 01-02 000431
0004840 01-02 000432
0004823 01-02 000415
0004830 01-02 000422
0004831 01-02 000423
0004832 01-02 000424
0004839 01-02 000431

5 Answers 5

3

Put notepad ++ search and replace in regex mode and search for ^[^0-9].*\r\n replace with you should leave blank

make sure . does not match new line Picture below of settings and output enter image description here

1

Regex to find anything other than your bank account numbers looks like:

^((?!\d{7}\s\d{2}-\d{2}\s\d{6}).)*$

This searches for anything other than 7 digits followed by a space and then 2 digits followed by a hyphen and then other 2 digits and another space and 6 final digits.

You can use this to Mark all the lines that match this pattern and then remove the Marked Lines.

1

Instead of Find go to Mark tab. Find all lines that match "^000", enable option "Bookmark line", and click "Mark all". All lines similar to "0004829 01-02 000421" will be bookmarked.

Now remove all remaining lines: Search > Bookmark > Remove unmarked lines.

EDIT: Instead of "^000" better use "^[0-9]{3}".

1
  • @user1281385 I edit the answer. Your answer is simpler and should be the accepted answer. Mine answer uses different approach (bookmarks) that can in some other cases be simpler. Nov 7, 2013 at 12:16
0

Using vim, the regex would be :

g/^Bank/,/^Applicants/d
0

Have a try with:

Find what: Bank.+?Applicants\r?\n
Replace with: <nothing>

then click on Replace all.

Make sure you have checked Regular expression and dot matches newline

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.