[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
help with regular expression formation
From: |
Mickey Ferguson |
Subject: |
help with regular expression formation |
Date: |
Mon, 31 Mar 2008 11:23:13 -0700 |
I'm generating output from a grep command, which I then want to process in
grep again, filtering out my unwanted text. In this specific example, I
want to filter out all lines that start with zero or more white space,
followed by the comment characters "//". Here is what I thought I would
use:
grep StopProductServices *.rul *.h | grep ^\s*[^/]
The first grep obviously finds all occurrences of StopProductServices within
all *.rul and *.h files. Then that output is piped into grep, with the
intent being to start at the beginning of the line (the caret), allow any
amount of white space (zero or more), and then match only if the first
non-white space charater is NOT a forward slash. What it appears to be
doing is to match the exact opposite of what I want.
To break it down a little, I first produced the output from the first grep,
which is used for the pipe:
->grep StopProductServices *.rul *.h
NTService.rul:// FUNCTION: StopProductServices(sProduct)
NTService.rul:// 03/24/08 MSF - Make StopProductServices() take an
additional parameter to
NTService.rul:function StopProductServices(sProduct)
NTService.rul:// 03/24/08 MSF - Make StopProductServices() take an
additional parameter to
NTService.rul:// Function: SafeStopProductServices
NTService.rul:// 03/24/08 MSF - Make StopProductServices(),
SafeStopProductServices() and
NTService.rul:function SafeStopProductServices(sProduct)
NTService.rul: bServicesStopped = StopProductServices(sProduct);
NTService.rul:// 03/24/08 MSF - Make StopProductServices(),
SafeStopProductServices() and
Setup.rul:// - Use Start... and StopProductServices() to stop
VESTA and
Setup.rul:// 03/31/08 MSF - Use Start... and StopProductServices() to stop
VESTA and
Setup.rul:// 03/31/08 MSF - Use Start... and StopProductServices() to stop
VESTA and
Setup.rul: StopProductServices(@PRODUCT_NAME);
Setup.rul: StopProductServices(VESTA_VIEW);
NTService.h:// 09/07/07 MSF - New functions StopProductServices(),
NTService.h:// SafeStopProductServices() and
DisableProductServices().
NTService.h:// 03/24/08 MSF - Make StopProductServices(),
SafeStopProductServices() and
NTService.h:prototype StopProductServices(STRING);
NTService.h:prototype SafeStopProductServices(STRING);
Then I ran the full command, and you can see that the output is not at all
what I expected:
[11:06:39]: *** C:\WIP\VESTA\Installer\Script Files ***
->grep StopProductServices *.rul *.h | grep ^\s*[^/]
NTService.rul:// FUNCTION: StopProductServices(sProduct)
NTService.rul:// 03/24/08 MSF - Make StopProductServices() take an
additional parameter to
NTService.rul:// 03/24/08 MSF - Make StopProductServices() take an
additional parameter to
NTService.rul:// Function: SafeStopProductServices
NTService.rul:// 03/24/08 MSF - Make StopProductServices(),
SafeStopProductServices() and
NTService.rul:// 03/24/08 MSF - Make StopProductServices(),
SafeStopProductServices() and
Setup.rul:// - Use Start... and StopProductServices() to stop
VESTA and
Setup.rul:// 03/31/08 MSF - Use Start... and StopProductServices() to stop
VESTA and
Setup.rul:// 03/31/08 MSF - Use Start... and StopProductServices() to stop
VESTA and
NTService.h:// 09/07/07 MSF - New functions StopProductServices(),
NTService.h:// SafeStopProductServices() and
DisableProductServices().
NTService.h:// 03/24/08 MSF - Make StopProductServices(),
SafeStopProductServices() and
Here is what I thought I would get:
NTService.rul:function StopProductServices(sProduct)
NTService.rul:function SafeStopProductServices(sProduct)
NTService.rul: bServicesStopped = StopProductServices(sProduct);
Setup.rul: StopProductServices(@PRODUCT_NAME);
Setup.rul: StopProductServices(VESTA_VIEW);
NTService.h:prototype StopProductServices(STRING);
NTService.h:prototype SafeStopProductServices(STRING);
- help with regular expression formation,
Mickey Ferguson <=