Would like to Retain a line if following match a pattern?

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

osiwan
Posts: 2
Joined: Thu May 12, 2005 11:04 pm

Would like to Retain a line if following match a pattern?

Postby osiwan » Thu May 12, 2005 11:27 pm

Hello,
I'm new to TextPipe.
I would like to remove line matching a pattern but not if the following line contains another patern

Here my file.
Support #1 : "Full"
Restore started 13:11
Directory\\MOZART\G$\
mirror.log 1359483 31/03/05 18:31
robo.bat 229 31/03/05 18:10
Directory\\MOZART\G$\DATA
Directory\\MOZART\G$\DATA\SYSTEM
desktop.ini <H> 65 28/04/05 11:18

If would like to keep line containing "/"
Remove line started by Directory only il the following line do no contains "/"

Result should be:
Directory\\MOZART\G$\
mirror.log 1359483 31/03/05 18:31
robo.bat 229 31/03/05 18:10
Directory\\MOZART\G$\DATA\SYSTEM
desktop.ini <H> 65 28/04/05 11:18

Thanks for any advice.

User avatar
DataMystic Support
Site Admin
Posts: 2138
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Postby DataMystic Support » Fri May 13, 2005 5:38 pm

Try this perl pattern

Code: Select all

(Directory[^\r\n]*\r\n)[^\r\n/]*\r\n


Replace with

Code: Select all

$1


Bonus marks if you can tell me what this does!
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

osiwan
Posts: 2
Joined: Thu May 12, 2005 11:04 pm

Postby osiwan » Fri May 13, 2005 7:11 pm

I've done a test with a remove matching and remove non-matching, but I should have missed something. I get the same output or a empty one.

Regards.

User avatar
DataMystic Support
Site Admin
Posts: 2138
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Postby DataMystic Support » Mon May 16, 2005 9:31 am

Ok. The best way to handle this is to mark the 'good' lines, then remove all other 'Directory' lines. Here is a filter list to do this:

|--Perl pattern [(Directory[^\r\n]*\r\n)([^\r\n]*/[^\r\n]*\r\n)] with [##$0]
| [ ] Match case
| [ ] Whole words only
| [ ] Case sensitive replace
| [ ] Prompt on replace
| [ ] Skip prompt if identical
| [ ] First only
| [ ] Extract matches
| Maximum text buffer size 4096
| [ ] Maximum match (greedy)
| [ ] Allow comments
| [X] '.' matches newline
| [ ] UTF-8 Support
|
|--Remove matching lines [^Directory]
| [ ] Include line numbers
| [ ] Include filename
| [ ] Match case
| [ ] Count matches
| Pattern type: 0
| Context before: 0
| Context after: 0
|
|--Perl pattern [##Directory] with [Directory]
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: No registered users and 1 guest