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.
Would like to Retain a line if following match a pattern?
Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators
- DataMystic Support
- Site Admin
- Posts: 2227
- Joined: Mon Jun 30, 2003 12:32 pm
- Location: Melbourne, Australia
- Contact:
Try this perl pattern
Replace with
Bonus marks if you can tell me what this does!
Code: Select all
(Directory[^\r\n]*\r\n)[^\r\n/]*\r\n
Code: Select all
$1
- DataMystic Support
- Site Admin
- Posts: 2227
- Joined: Mon Jun 30, 2003 12:32 pm
- Location: Melbourne, Australia
- Contact:
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]
|--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]