Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Ruby Basic string operatiors
SUBMITTED BY:
Guest
DATE:
May 21, 2015, 2:05 p.m.
FORMAT:
Ruby
SIZE:
445 Bytes
Raw
Download
Tweet
HITS:
742
Go to comments
Report
Example
-
001
:
String
Length
puts
'That is an object'
.
size
# => prints 17
Example
-
002
:
Reversing
puts
'This is not a palindrome'
.
reverse
# => prints 'emordnilap a ton si sihT'
Example
-
003
:
Single
substitution
puts
'a banana'
.
sub
(
'a'
,
'*'
)
# => prints '* banana'
Example
-
004
:
Global
substitution
puts
'a banana'
.
gsub
(
'a'
,
'*'
)
# => prints '* b*n*n*'
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus