Re: Expression problem




K.J. 44 wrote:
Thank you very much for your help and suggestions. I will try these
out.

Thanks!
xhoster@xxxxxxxxx wrote:
"K.J. 44" <Holleran.Kevin@xxxxxxxxx> wrote:
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) {

.
.
.

I'm not sure what lead up to $details[$i] , but you ain't in VB land
anymore.. Perl has a much cleaner syntax of which you can take
advantage, such as:

for ( @ details )
{
next unless /\bworkstation\b\bname:\b\s\b([0-9A-Za-z_\-])+\b/; #
this is your regex
.
.
# at this point you can "do stuff" with $1 or whatever...
}

Avoid INDEXED arrays- you seldom need to carry that motley syntax into
The Land of Perl; enjoy the beautiful landscape that IS Perl!

PS: [0-9A-Za-z_\-] looks a LOT like \w

.