Expression problem



I have the two following regular expressions. I am not very good at
writing these yet. I am parsing some logs looking for some key words,
then taking the text after them.

if ($details[$i] =~ /\bworkstation\b\bname:\b\s\b[0-9A-Za-z_\-]+\b/i) {
($nothing, $hostName[$i]) = split(/:/, $&);
}
if ($details[$i] =~ /\buser\b\bname:\b\w+/i) {
print("The username is: $&");
($nothing, $username[$i]) = split(/:/, $&);
}

The $details array is read in from a text file and this works fine.
What I want to do is search the $details text for certain key words,
then take the text right after. The first if statement

Find the word Workstation followed by a space followed by name:
followed by a space followed by a string of characters including word
characters and hyphens. if the match is found, take only the text
after the : as the workstation name.

The second part is along the same lines for username.

Find the word user followed a space followed by the word name: followed
by a space followed by a string of word characters. Split at the : as
the username found.

These do not seem to be finding matches when I can see them in the log
file. Where am I messing up?

Thanks.

.



Relevant Pages

  • Re: Expression problem
    ... I am parsing some logs looking for some key words, ... The $details array is read in from a text file and this works fine. ... What I want to do is search the $details text for certain key words, ... followed by a space followed by a string of characters including word ...
    (comp.lang.perl.misc)
  • Re: string manipulation experts...
    ... > These logs are created by an application that was developed by an outside ... > archiving piece, but having a problem with the renaming and am seeking ... > I've tried to count the characters and take the necessary ones out of the ... > the day is 2 characters and month is a single character. ...
    (microsoft.public.scripting.vbscript)
  • Re: string manipulation experts...
    ... Traverse the name portion of the string from right to left in 1 char units ... > These logs are created by an application that was developed by an outside ... > archiving piece, but having a problem with the renaming and am seeking ... > I've tried to count the characters and take the necessary ones out of the ...
    (microsoft.public.scripting.vbscript)
  • string manipulation experts...
    ... Date is in the format YYYYmd ... These logs are created by an application that was developed by an outside ... archiving piece, but having a problem with the renaming and am seeking ... I've tried to count the characters and take the necessary ones out of the ...
    (microsoft.public.scripting.vbscript)
  • Re: string manipulation experts...
    ... A couple of questions concering the AppName. ... determine the app name (n characters being the same length as the list ... >These logs are created by an application that was developed by an outside ... >archiving piece, but having a problem with the renaming and am seeking ...
    (microsoft.public.scripting.vbscript)