Saturday 14 September 2013

How to use String Manipulation in Ruby

                        String Manipulation


Print a string :

irb(main):001:0> Puts " this is ruby"
If you find out the length of string :
irb(main):001:0> Puts "this is ruby ".length
Use uppercase letter print on screen :
irb(main):001:0> Puts " this is ruby" .upcase

Method of String testing :

Expression                              O/P
"Ruby"+Ruby                        RubyRuby
"Ruby".capitalize                    Ruby
"Ruby".downcase                   ruby
"Ruby".upcase                        RUBY
"Ruby".chop                           Rub
"Ruby".next                            Rub
"Ruby".reverse                       ybuR
"Ruby".sum                   
"Ruby"_swapcase                  ybuR
"Ruby".up case.reverse          YBUR
"Ruby".up case.reverse.next   RUBZ

No comments:

Post a Comment