Assign new material to submesh?

If I have a object with several submeshes, and all those submeshes are using the same material, how can I pick out a specific submesh and set its material to something else? I guess im mostly confused how you would be able to find the submeshes. If the submeshes used different materials I could simply get array of materials and change the one I want. But I cant do that in this case because the material is the same for all submeshes.

var allMaterials = renderer.materials;
allMaterials[numberToChangeHere] = someMaterial;
renderer.materials = allMaterials;