我有以下问题。
如果我们使用小解析器(little_parser)的方法,它应该返回:
如果我们运行little_parser(phrase_2),它应该只返回以下内容:
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)的方法,它应该返回:
["chrome", "firefox", "ie"]
If the phrase was:
phrase_2 = "I don't use Opera"
如果我们运行little_parser(phrase_2),它应该只返回以下内容:
["opera"]
最简单的方法是怎样做?