Improves regex for replacing classes.