I would like to use a regex to get every variant of a method name like this:
method_name = "my_special_title"
method_name_variants = ["my_special_title", "special_title", "title"]
I can do this with:
r = /((?:[^_]*_)?((?:[^_]*_)?(.*)))/
r.match("my_special_title").to_a.uniq
=> ["my_special_title", "special_title", "title"]
is it possible to have a arbitrary method length so we can have:
"my_very_special_specific_method" => ["my_very_special_specific_method", "very_special_specific_method", "special_specific_method", "specific_method", "method"]
Here’s one way: