我有以下问题。
phrase = "I love Chrome and firefox, but I don't like ie."
browsers = ["chrome", "firefox", "ie", "opera"]
def little_parser ( str )
# what's the best way to retrieve all the browsers within phrase?
end
如果我们使用方法 little_parser(phrase),它应该返回
["chrome", "firefox", "ie"]
如果这句话是:
phrase_2 = "I don't use Opera"
如果我们运行 little_parser(phrase_2),它应该只返回:
["opera"]
我该如何以最简单的方式做到这一点?