Script is selecting all the objects (unwanted)
All strings &quot;start with nothing&quot;.
Simple test in python console
&gt;&gt;&gt; x = &quot;xxx&quot;
&gt;&gt;&gt; x.startswith(&quot;&quot;)
True

Similarly with your operator since the default value when not set of a string property is &quot;&quot;.
Either test for this, or give it some default.
Note, there is already a similar op, to select all objects that start with &quot;Cube&quot;
&gt;&gt;&gt; bpy.ops.object.select_pattern(pattern=&quot;Cube*&quot;)
{'FINISHED'}