One night before my coding bootcamp begins, and I'm working my way through exercises in the prep work that I didn't get to this winter. Here is a little Ruby redactor I finally got to work !
puts "Text to search through : "
text = gets.chomp
puts "words to redact : "
redactstring = gets.chomp
word = text.split(" ")
w = []
word.each do |word|
w.push(word)
end
redact = redactstring.split(" ")
r = []
redact.each do |redact|
r.push(redact)
end
i=0
while i<w.length
w.each do |word|
if r.include?word
print "REDACTED "
else
print word + " "
end
i+=1
end
end
Oldest comments (0)