Refining Search Criteria

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
TextPad_Newbie
Posts: 2
Joined: Tue May 22, 2012 3:47 pm

Refining Search Criteria

Post by TextPad_Newbie »

I am trying to remove some lines from group of text files using Find and Replace. I have approx. 6,000 of these files. The lines I am trying to remove are:

REM net use lpt1: \\abcprint\abfde012p
REM net use lpt2: \\efgprint\kub068p
REM net use lpt3: \\hklprint\abc????p

In the Search > Find in Files window I search for net use lpt This returns all the files with the entries I am looking to remove. I then select and open the files and then use the Search > Replace window, I enter .*[lpt]*p$ in the Find What field and leave the replace field blank so that it will remove the line.

My issue is that it is removing other lines that I do not want it to. For example it is removing:

rem net use y: \\abc\app
:: Check if on XenApp
cscript y:\update\printeradd.vbs /d \\abc\xyz025p

Here is an example of the text file:

@echo off
::::net time \\atl /set /y > nul
rem net use y: \\abc\app
Net Use U: \\ADCFS1\Users\test
:: Check if on XenApp
cscript y:\update\printeradd.vbs /d \\abc\xyz025p
cscript y:\update\printeradd.vbs \\abc\xyz027c
cscript y:\update\printeradd.vbs \\abc\xyz026m
REM net use lpt1: \\abcprint\abfde012p
REM net use lpt2: \\efgprint\kub068p
REM net use lpt3: \\hklprint\abc????p
C:\windows\lmscript.$$$
@echo on

I am sure that this is childsplay but my inner child has run away. What do I need to use in the Find What field to only select the lines containing the rem net use lpt variable? Any help would be greatly appreciated.
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

the lines you want to delete contain the characters lpt in exactly this order.
What you are looking for are lines that
start with whatever
have any number of one of the letters l or p or t
end with a p.

.*lpt.*p$
is probably the expression you want to use

This searches for:
start with whatever
the letters l and p and t in exactly this order
whatever
end with p
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

And if you want to remove the entire line, including its line terminator, use
.*lpt.*p\n
TextPad_Newbie
Posts: 2
Joined: Tue May 22, 2012 3:47 pm

It worked

Post by TextPad_Newbie »

ben_josephs wrote:And if you want to remove the entire line, including its line terminator, use
.*lpt.*p\n
Thanks it worked. This gets me on the right track.
Post Reply