Does anyone knows where to find the regular expression C# and/or VB.NET uses to validate its data types? say to validate doubles or floats, int, shorts, longs and so on?
I've been looking around the web and all the regular expressions I found are crappy and jerky not functioning for all cases. So I say let's return to the source! I bet those MS compilers gotta have a hell of good regular expressions to validate the code programmers
Thanx in advance.
I'll assume, that you mean validating string versions, of these datatypes? Otherwise, regular expressions will not do much. That said, you'll probably want to look at the specifications for each language. I don't know about VB.NET, but you can find C#'s
here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vclrfcsharpspec_c.asp You'll notice that there only exists an "integer-literal" and "real-literal". Exactly what this is taken as, I'll assume depends on what it's either prefixed,
or postfixed with, or what the context is. As such, there are no explicit regular expressions (or even implicit, the definition is grammatical, not lexical).
I don't think this is the right tool.
Regex's are for finding patterns in varrying string data. Numbers (the data types you mentioned) are arithmatic and should be handled that way.
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.