Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Steps to get a substring from a string

by vinoth.ree (Monsignor)
on Jul 21, 2015 at 16:42 UTC ( [id://1135660]=note: print w/replies, xml ) Need Help??


in reply to Re: Steps to get a substring from a string
in thread Steps to get a substring from a string

Hi Corion

How about the 2nd case,2) I have name=servername , i want to still capture the first part in a variable. In this your code will not work. we need to match a-zA-Z character after =

my $str='name=host.com' my ($match) =$string=~/=([a-zA-Z]+)/;
Update:

Updated the regex part as per CountZero's node Re^3: Steps to get a substring from a string


All is well. I learn by answering your questions...

Replies are listed 'Best First'.
Re^3: Steps to get a substring from a string
by CountZero (Bishop) on Jul 21, 2015 at 17:05 UTC
    According to RFC952 and RFC-1123, the hostname should only consists of the ASCII letters 'a' through 'z' (in a case-insensitive manner), the digits '0' through '9', and the hyphen ('-'). Spaces and underscores are not allowed!

    Update: added "and underscores"

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics
      ++CountZero

      Oh Sorry! Actually I considered only string part and written the script, I will update the same. Thank you CountZero


      All is well. I learn by answering your questions...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1135660]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-04-24 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found