Re: Expression problem
- From: Tad McClellan <tadmc@xxxxxxxxxxxxxx>
- Date: Mon, 27 Nov 2006 18:35:31 -0600
Christian Winter <thepoet_nospam@xxxxxxxx> wrote:
So the first piece of code could be cut down to
if( $details[$i] =~ /\bworkstation\sname:\s([0-9A-Za-z_\-]+)/i )
{
$hostName[$i] = $1;
}
There's still room for improvement, like
adding an //x modifier, particularly if you are "not very good"
at grokking regexes:
if ( $details[$i] =~ /\bworkstation
\s
name:
\s
(
[0-9A-Za-z_-]+
)
/ix
)
e.g. removing A-Z from
the character class, as you are giving the /i modifier anyway,
so both upper and lowercase characters will be matched.
and removing the backslash. Hyphen is not meta in a character
class if it is first or last in the class.
--
Tad McClellan SGML consulting
tadmc@xxxxxxxxxxxxxx Perl programming
Fort Worth, Texas
.
- References:
- Expression problem
- From: K.J. 44
- Re: Expression problem
- From: Christian Winter
- Expression problem
- Prev by Date: Re: Interactive programs & Teeing
- Next by Date: Re: Windows CE, Windows Mobile
- Previous by thread: Re: Expression problem
- Next by thread: Re: Expression problem
- Index(es):
Relevant Pages
|