I see couple of questions on multiple regex patterns in different contexts but I am unable to get a grip on it.
I have a string str = "Hello, how are you. Hello, I am lloyds"
in which I would like to apply multiple patterns to extract all Hello
s and all ll
s in one go to get ["Hello", "Hello", "ll", "ll", "ll"]
. How do I do it?
The only way I was able to do is (which is not multiple patterns in one go)
str = "Hello, how are you. Hello, I am lloyds"
a = []
a << str.scan(/Hello/)
a << str.scan(/ll/)
a.flatten