PHP to Ruby
Convert PHP code into Ruby!
-
rtrim
Posted on June 19th, 2009 No commentsThe rtrim function strips whitespace (or other characters) from the end of a string.
PHP
echo rtrim('Work Hard. Play Harder.', ' Play Harder.'); => // 'Work Hard.'
Ruby
substitute = 'Play Harder.'; puts "Work Hard. Play Harder.".gsub(/[#{substitute}]+$/, '') => # 'Work Hard.'
Leave a reply


