Regular Expression Help please

Discussion in 'Perl Misc' started by Max Adams, Aug 29, 2003.

  1. Max Adams

    Max Adams Guest

    All,

    I have this regular expression which a guy here provided yesterday, this
    regexp parses an executable name from a log file, however it only works when
    the executable name is part of a fully qualified name, and not when only the
    executable name is specified. Here is my scenario:

    The regexp will successfully parse "Stages.exe" for the first entry in the
    log file, but it will not parse "Stages.exe" in the second entry.

    ..... [SERVER06:c:\workgroup\Stages.exe:2236: ....
    ..... [SERVER06:Stages.exe:2236 ....

    This is the regular expression:

    my @extract = ($_ =~ /.*\\([^\\]+\.exe).*SQL = ([^;]+).* [0-9]{8} ([0-9:
    \/]+) .*/i);

    This is a complete entry from the log file.

    [SERVER05] EnumServerProceses : (0x31fdb30)
    [SERVER06:c:\workgroup\Stages.exe:2588:{56DC057D-2D02-4A2A-A308-B625555C6345
    }] CEnumServerProcesses::GenericExecute() : SQL = begin
    PA_Stages.PR_GetProcessList:)TASKID); end; : CursonName = NULL : Options = 6
    : SessionID = 12127793 11:59:29 27/08/2003 tid:1076 pid:2304
    tick:16640900672768 .\EnumServerProcesses.cpp (55)

    Note again that the executable path is not guarenteed to exist.

    Can anyone suggest how I can modify this regexp to be independant of the
    path being specified please.

    PT
     
    Max Adams, Aug 29, 2003
    #1
    1. Advertisements

  2. Max Adams

    Anno Siegel Guest

    Why don't you ask "the guy here"? He came up with the thing.
    The initial ".*" in the regex does nothing, nor does the final one.
    Leave them off.
    So how many entries are this? Where does one end and the other begin?
    And why haven't you supplied one of the form that isn't matched? Please
    be considerate and give us useful test data. What you provided needs
    a lot of guess work.

    Try this:

    /:(?:.*\\)?([^\\]+\.exe).*SQL = ([^;]+).* [0-9]{8} ([0-9:\/]+) /i

    Since you don't say in which ways the log data can vary, there's no
    way of knowing if it will work in all cases. I'm assuming that the
    first colon in a line marks the beginning of the file name.

    Anno
     
    Anno Siegel, Aug 29, 2003
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.