Hi friends,
In ruby we can interchange characters in a string easily by using “.tr” methods this is a good useful method to perform some replace actions on strings.
Returns a copy of str with the characters in from_str replaced by the corresponding characters in to_str.
Here are few examples on this method:
‘This is the Example for Exchange the strings.‘.tr ‘aeiou’, ‘_‘
=> “Th_s _s th_ Ex_mpl_ f_r Exch_ng_ th_ str_ngs.”
‘This is the Example for Exchange the strings.’.tr ‘a-k’, ‘*’
=> “T**s *s t** Ex*mpl* *or Ex***n** t** str*n*s.”
‘This is the Example for Exchange the strings.’.tr ‘a-z’, ‘s’
=> “Tsss ss sss Essssss sss Esssssss sss sssssss.”
‘This is the Example for Exchange the strings.’.tr ‘aeiou’, ‘5’
=> “Th5s 5s th5 Ex5mpl5 f5r Exch5ng5 th5 str5ngs.”
Dowenload jar are invaild plz halp me.