I am trying to find strings in an array that match multiple regular expression patterns. I figured out how to do this for one pattern as below:
spamWords = Regexp.new("Delighted")
spamCount1 = 0
spamArray.each do |word|
if word =~ spamWords
spamCount1 +=1
end
end
p spamCount1
I iterated over an array of spamWord strings, but I was wondering if there is a simpler way of doing this.
smapArray.count(&spamWords.method(:=~)).