[a-zA-Z_:]([a-zA-Z0-9_:.])*
Would this do?
Do you mean XML element names? If so, no, that's too exclusive, there are lots of valid characters that that doesn't cover. More in the spec here and here:
NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] |
[#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] |
[#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] |
[#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] |
[#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 |
[#x0300-#x036F] | [#x203F-#x2040]
Name ::= NameStartChar (NameChar)*
EDIT:
.NET also has the method XmlConvert.VerifyName(string).
From Wikipedia:
Unicode characters in the following code point ranges are valid in XML 1.0 documents:
Unicode characters in the following code point ranges are always valid in XML 1.1 documents:
The preceding code points are contained in the following code point ranges which are only valid in certain contexts in XML 1.1 documents:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With