Using regexp in Ruby/TkText search

This works (not using an RE):

p1 = $analysis.search(“the”, ‘1.0’, stopindex=‘end’)

I want to use a regular expression in the search:

p1 = $analysis.search("[a-z][A-Z]", ‘1.0’, stopindex=‘end’,
regexp=‘True’)

but that fails “in `search’: wrong number of arguments (4 for 2…3)”

The equivalent line that works fine in Python/TkText is:

p1 = st.search("[a-z][A-Z]", ‘1.0’, stopindex=END, regexp=True)

My question: how do I specify I am using a regular expression when
searching a Ruby TkText box. Thanks.

I haven’t worked with Tk yet, but taking a look at the docs,
Class: Tk::Iwidgets::Scrolledtext (Ruby 2.1.2),
I think you should just let ruby handle whatever you throw at it. We can
use the class or kind_of? method in ruby to check the type of an object.
Try

$analysis.search(/my_regexp/, ‘1.0’, ‘end’)

Search seems to use String#index, which accepts both Strings and
Regexps. Regexp are written betweeen slashes in ruby.

That works perfectly. Thank you!