Re: Expression problem
- From: "Mr P" <MisterPerl@xxxxxxxxx>
- Date: 28 Nov 2006 07:37:05 -0800
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
.
- Follow-Ups:
- Re: Expression problem
- From: Dr.Ruud
- Re: Expression problem
- References:
- Expression problem
- From: K.J. 44
- Re: Expression problem
- From: xhoster
- Re: Expression problem
- From: K.J. 44
- Expression problem
- Prev by Date: Re: regex matching exactly 10 digits
- Next by Date: PS: Expression problem
- Previous by thread: Re: Expression problem
- Next by thread: Re: Expression problem
- Index(es):