Tech Off Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Regular Expressions

Back to Forum: Tech Off
  • User profile image
    raptor3676

    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 write.

    Thanx in advance.

    Raptor3676

  • User profile image
    SvendTofte

    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).

  • User profile image
    themaffeo

    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. 

    I think your answer here is some pretty simple custom javascript if you're doing the validation on the client or some pretty simple code validation on the server.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.