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 (Monsignor)
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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1077378]
[1nickt]: Morning Marto!

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2017-12-17 13:21 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (464 votes). Check out past polls.