you are in: codestackercodes [RSS]string manipulation

string manipulation Delicious Email

show/hide lines
   1  # using 'insert'
   2  
   3  myString = "Paris in Spring" 
   4  myString.insert 8, " the"  # returns "Paris in the Spring"
   5  
   6  # using 'gsub' for remove non-alphabetic characters from a string
   7  
   8  myString = "Only a test!!!" 
   9  myString.gsub(/[^a-zA-Z|\s]/,'') # returns "Only a test"
  10  
  11  # using 'gsub' for search & replace
  12  
  13  myString = "I love ASP"
  14  myString.gsub('ASP','Ruby') # returns "I love Ruby"
created by leozera — 07 September 2008 — get a short url — tags: ruby sample string embed

Comments



We dont send spam :)

If checked, it's highlights your comment
simple_captcha.jpg
Are you a human? Type the code from the image