Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: checking particular part of string

by vinoth.ree (Prior)
on Mar 07, 2014 at 13:35 UTC ( #1077378=note: print w/ replies, xml ) Need Help??

in reply to checking particular part of string

Hi sumandas,

In your code you no need to use $str =~ m/na/ you can directly use the $str =~ s/na//gi; code, as you need to check the "na" string to be matched at the end of the srtring, perl has the special chater "$" used to match at the end of the sctring, so $str =~ s/na$//gi; this will match the "na" at the end of the string, now u want that "na" at the end of the string to be converted to UPPERCASE "na", so we need to get the same substring to replace, so we need to group it, as $str =~ s/(na)$/uc($1)//gi;, the grouped string will be available in $1 special variable, and use the uc() BIF to convert the matched substring to uppercase.

All is well

Comment on Re: checking particular part of string
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2015-11-25 10:57 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (673 votes), past polls