By Alvin Alexander. Last updated: June 4, 2016
Ruby substring FAQ: I can't find a Ruby substring method, how can I tell if one Ruby string contains another string?
Solution: I expected the Ruby String class to include a method named substring, but it doesn't. My personal disappointment aside, it does have a method named include? that works the way I expected it to. Here's a simple example, using the irb
environment to perform a few tests.
>> a = 'hello world' => "hello world" >> a.include? 'ell' => true >> a.include? 'YO' => false
If you were looking for a Ruby substring method, I hope that was helpful.