Forum: Ruby using regexp in Ruby/TkText search

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
6d0b340e28174f4bd1bfda492f025825?d=identicon&s=25 Roger F. (roger_f)
on 2014-08-10 10:10
This works (not using an RE):

p1 = $"the", '1.0', stopindex='end')

I want to use a regular expression in the search:

p1 = $"[a-z][A-Z]", '1.0', stopindex='end',

but that fails "in `search': wrong number of arguments (4 for 2..3)"

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

p1 ="[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.
4a65f01f7ece0b720bdb0de3c3db089e?d=identicon&s=25 Dansei Yuuki (blutorange)
on 2014-08-10 11:33
I haven't worked with Tk yet, but taking a look at the docs,,
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.

> $, '1.0', 'end')

Search seems to use String#index, which accepts both Strings and
Regexps. Regexp are written betweeen slashes in ruby.
6d0b340e28174f4bd1bfda492f025825?d=identicon&s=25 Roger F. (roger_f)
on 2014-08-10 11:36
That works perfectly. Thank you!
This topic is locked and can not be replied to.