Hi everyone,
How can I create alternatives from a list of strings to be used as a string pattern in StringPosition. For example, if my function is fed
{"cat","dog","bird}
I want
"cat" | "dog" | "bird"
But if my list has only two strings in it
{"cat","dog"}
I want
"cat" | "dog"
In other words, I want to be able to generate alternatives from a list of unknown length.
I guess a related question is, What is the difference between using
StringPosition[myText,"cat"|"dog"~~WordBoundary]
and
StringPosition[myText,{"cat","dog"}~~WordBoundary]
because both seems to work the same in my tests?
Regards,
Gregory