I need a method to take in string (which are to be used as Element names in an xml doc) and replace invalid characters with an underscore.
NOTE: Names in XML can contain English letters (of any case), numbers (0-9), underscores (_), periods(.) and hyphens (-). Names cannot begin with a number, period or hyphen. Names can also contain a colon, but the use of colons outside of namespaces should be avoided.
Therefore I need a regular expression to replace any character that is not valid in an XML name.