Thursday, 12 September 2013

[Ruby]How to search multiple keywords in a single string line

[Ruby]How to search multiple keywords in a single string line

I am new to ruby. I want to know how to find if multiple keywords exist or
not in a single line. For example, a line "Hello, how are you?", if
"Hello" or "how" exits, return true. I try to use reg exp like
/Hello|how/, but performance is not good when there are lots of lines to
process. Maybe Regexp suits this use case, but I cannot find specific
example in google.
Thanks for the help!

No comments:

Post a Comment