CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
help

 



neighborhoodX
New User

Sep 10, 2012, 2:28 AM

Post #1 of 3 (7382 views)
help Can't Post

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

Post #2 of 3 (7378 views)
Re: [neighborhoodX] help [In reply to] Can't Post

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

Post #3 of 3 (6585 views)
Re: [neighborhoodX] help [In reply to] Can't Post

http://gskinner.com/RegExr/

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives