Taking out a similar lines

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
Siaruzb
Posts: 20
Joined: Thu Jul 27, 2006 6:02 pm

Taking out a similar lines

Post by Siaruzb »

Hello,

I am creating a following Index file:

Q1N: READ/LOOKED PRINTED EDTN OF PBLCTNS Table#1-3
Q1N: READ/LOOKED PRINTED EDTN OF PBLCTNS Table#2
Q1N: READ/LOOKED PRINTED EDTN OF PBLCTNS Table#3
Q2: NUMBER OF PRINT EDITIONS YOU RD - AA Table#4-6
Q2: NUMBER OF PRINT EDITIONS YOU RD - AA Table#5
Q2: NUMBER OF PRINT EDITIONS YOU RD - AA Table#6

Is there any way to take out 2nd, 3rd, 5th and 6th lines? Thank you for your comments and suggestions.
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Search for: (^Q.*)\n.*\n.*\n
Replace with: \1\n

Regular Expression is checked. Using POSIX in Editor

You will have to repeatedly click on ReplaceNext vs. Replace All.
But you could make that into a macro and run it until all are done.
Hope this was helpful.............good luck,
Bob
Siaruzb
Posts: 20
Joined: Thu Jul 27, 2006 6:02 pm

Post by Siaruzb »

Thank you for suggestion.

I have put:
SEARCH\REPLACE\Find What: (^Q.*)\n.*\n.*\n
SEARCH\REPLACE\Replace with: \1\n

I have checked Regular Expression. But can not find an Editor....
Siaruzb
Posts: 20
Joined: Thu Jul 27, 2006 6:02 pm

Post by Siaruzb »

I can run syntax above. But this syntax doesn't work. The syntax is recognised the similar lines but takes out all 3 lines.

Also (^Q.*)\n.*\n.*\n is not working.

Roght one is - ^Q.*\n.*\n.*\n

Can anybody help me with this?

Thanks.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

What Bob meant was that you should use Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
Siaruzb
Posts: 20
Joined: Thu Jul 27, 2006 6:02 pm

Post by Siaruzb »

Thanks Ben. But again, it doesnt work properly. We have to start cheking the lines from bottom to top. The syntax taking out wrong lines.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

I have no idea what you mean.

You are saying that the rule as Bob (quite reasonably) understood it is incorrect. This rule divides the input into groups of 3 lines, starting at the top, and deletes the 2nd and 3rd lines of each group.

Please explain more carefully exactly what you want converted into what and give examples that demonstrate this and show in what way Bob's suggestion doesn't work.
Siaruzb
Posts: 20
Joined: Thu Jul 27, 2006 6:02 pm

Post by Siaruzb »

OK.

I am creating the INDEX file. I have following list of tables.

Q1N: READ/LOOKED PRINTED EDTN OF PBLCTNS Table#1
Q1N: READ/LOOKED PRINTED EDTN OF PBLCTNS Table#2
Q1N: READ/LOOKED PRINTED EDTN OF PBLCTNS Table#3
Q2: NUMBER OF PRINT EDITIONS YOU RD - AA Table#4
Q2: NUMBER OF PRINT EDITIONS YOU RD - AA Table#5
Q2: NUMBER OF PRINT EDITIONS YOU RD - AA Table#6
Q11N: 1READ/LOOKED PRINTED EDTN OF PBLCTNS Table#11
Q11N: 1READ/LOOKED PRINTED EDTN OF PBLCTNS Table#12
Q11N: 1READ/LOOKED PRINTED EDTN OF PBLCTNS Table#13
Q12: 1NUMBER OF PRINT EDITIONS YOU RD - AA Table#14
Q12: 1NUMBER OF PRINT EDITIONS YOU RD - AA Table#15
Q12: 1NUMBER OF PRINT EDITIONS YOU RD - AA Table#16

Then I have to take out 2nd, 3th, 5th,6th, 12th, 13th, 15th and 16th lines. My final Index files should be like this:

Q1N: READ/LOOKED PRINTED EDTN OF PBLCTNS Table#1-3
Q2: NUMBER OF PRINT EDITIONS YOU RD - AA Table#4-6
Q11N: 1READ/LOOKED PRINTED EDTN OF PBLCTNS Table#11-13
Q12: 1NUMBER OF PRINT EDITIONS YOU RD - AA Table#14-16

So is there any way to do that? Thanks
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

That's exactly what Bob's suggestion does, except for changing the numbers after the '#', which you didn't mention before. Did you follow his instruction to repeatedly click on Replace Next rather than click once on Replace All. You have to start at the top of the file, of course.
Siaruzb
Posts: 20
Joined: Thu Jul 27, 2006 6:02 pm

Post by Siaruzb »

OK. Got It. I had replaced All. Now its working. Great. Thanks.

Is there any way to put Table number too? Like after Table#1 put Table#1 - 3???

Thanks
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Find what: (.*)#(.*)\n.*#.*\n.*#(.*)\n
Replace with: \1#\2-\3\n

[X] Regular expression
Siaruzb
Posts: 20
Joined: Thu Jul 27, 2006 6:02 pm

Post by Siaruzb »

Thank you very much Ben.
Post Reply