[issue24896] XML: Use compiled regexes for replacing invalid characters in element names