[ create a new paste ] login | about

Link: http://codepad.org/Dcp1O0uB    [ raw code | output | fork ]

Ruby, pasted on Jan 6:
puts "Write message body:"
text = gets.chomp

puts "Write words to redact separated by space:"
redact = gets.chomp
redact.downcase!

redact_words = redact.split(" ")
redact_words.each do |r|


text_words = text.split(" ")
text_words.each do |b|
    if b.downcase == r
        print "REDACTED "
    else
        print b + " "
    end
end
end


=begin

Write message body:
 test one two three

Write words to redact separated by space:
 test three

REDACTED one two three test one two REDACTED ["test", "three"]
but I want to get this result: "REDACTED two REDACTED ["test", "three"]"

=end


Output:
1
2
Line 2: private method `chomp' called for nil:NilClass (NoMethodError)
Write message body:


Create a new paste based on this one


Comments: