I am trying to check if user input contains at least one of two possible words (from a csv), and I am having trouble coming up with the correct syntax for the RegExp. I’ve tried so many different ways of writing it, but I can’t get it. Here’s what I have that is the closest to it… but it only works if the first word (option1) is found, the second one (option2) is ignored completely.
You cannot use the || operator inside a PennController test command like that. The TextInput text test command accepts either a string or a regex as its argument—what you’re doing here is passing the first non-null disjunct, which will necessarily be new RegExp(variable.Option1) because this constructor will never return null (or undefined, etc).
Long story short, you want to build a single regex object that will match both Option1 and Option2, like this: new RegExp(variable.Option1+"|"+variable.Option2)