There are some code examples here:
https://forums.sketchup.com/t/selecting-specific-entity-group-or-component-by-name/11469These examples use the
== but you can use regular expressions:
http://ruby-doc.org/core-2.0.0/Regexp.htmlbegins with:
=~ /\A#{name}/Or the specific string "Handle" at start of string followed by: an
optional whitespace character, underscore or dash; followed by a literal pound sign (which I escape just in case);
followed by an
optional whitespace character; followed by one or more digit characters; just before the end of the string:
=~ /\AHandle(\s|-|_)?\#\s?\d+\z/... and to make it non-case
insensitive we can add a "i" switch at the end
outside the slashes:
=~ /\AHandle(\s|-|_)?\#\s?\d+\z/i
If you are using Ruby 2.0 or higher you can also use the
String#start_with?() method:
http://ruby-doc.org/core-2.0.0/String.html#method-i-start_with-3Finst.name.start_with?('Handle')... or for case insensitive convert to a title:
inst.name.capitalize.start_with?('Handle')