>>318
import bpy
for x in bpy.context.selected_bones:
 if x.name.find('end')== -1:
  x.select = False
bpy.ops.armature.delete()