Using (word|other) in str.include?

Using ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]

I’m going over an old script I wrote and I have an if statement that
basically goes like this:

do something if mystring.include?(“something (word1|word2): something”)

This script worked fine with this for months, but now I’m updating it
and re-“compiling” it with rubyscript2exe. I think I previously
“compiled” it with a prior version of ruby, so that could be the cause
of my current woes. Anyway, the (…|…) part is not working now.

I’m playing around with it in irb and it will only match mystring if I
place word1 or word2 directly into the compare string rather than using
(word1|word2). Does this ability not work anymore? Is there something
equally succint I can do rather than writing out two if statements?

James D. wrote:

do something if mystring.include?(“something (word1|word2): something”)

It surprises me quite a bit that that ever worked. Here’s what should
work:
do something if mystring =~ /something (word1|word2): something/

HTH,
Sebastian

Sebastian H. wrote:

James D. wrote:

do something if mystring.include?(“something (word1|word2): something”)

It surprises me quite a bit that that ever worked. Here’s what should
work:
do something if mystring =~ /something (word1|word2): something/

HTH,
Sebastian

yep, that works. Thanks!