ruby code example(9)
382 ワード
ruby code example(9)
line = "abc"
if line =~ /Perl|Python/ ##
puts "Scripting language mentioned: #{line}"
end
line.sub(/Perl/, 'Ruby') # replace first 'Perl' with 'Ruby'
line.gsub(/Python/, 'Ruby') # replace every 'Python' with 'Ruby'