Home: Perl Programming Help: Regular Expressions:
help



neighborhoodX
New User

Sep 10, 2012, 2:28 AM


Views: 12996
help

Hi, a beginner here. Can anyone help me to elaborate the following line. i need to modify the expression to change a target host. Thanks!

if( ($_ =~ m/^(\S+)\s+(\d+)\s+.*/i) ){


Laurent_R
Veteran / Moderator

Sep 10, 2012, 4:53 AM


Views: 12992
Re: [neighborhoodX] help

Hi,

If the special variable $_ matches:
start of string, followed by one or more non white space characters folowed by one or more white space characters followed by one or more digits followed by one or more digits followed by anything...

In addition, the parentheses lead to the following captures:
- the first series of non white characters is captured in variable $1
- the series of digits is captured into variable $2

The i option makes the match case insensitive, which is quite useless here since there is no upper or lower case letter.


rovf
Veteran

Oct 22, 2012, 4:46 AM


Views: 12199
Re: [neighborhoodX] help

http://gskinner.com/RegExr/