Computing Maximal Error-detecting Capabilities and Distances of Regular Languages