Below are some tables that are helpful for reference.
Originally Published: 9/27/2010
C# Data Types Value Range
Common Regular Expressions
States and Abreviations
|
Data Type
|
Range
|
|
System.Boolean bool
|
true or false
|
|
System.Byte byte
|
0 to 255
|
|
System.SByte sbyte
|
-128 to 127
|
|
System.Decimal decimal
|
-79,228,162,514,264,337,593,543,950,335 to 79,228,1 62,514,264,337,593,543,950,335
|
|
System.Double double
|
-1.79769313486232e308 to 1.79769313486232e308
|
|
System.Single float
|
-3.40282347E+38 to 3.40282347E+38
|
|
System.Int16 short
|
-32768 to 327678
|
|
System.Int32 int
|
-2,147,483,648 to 2,147,483,647
|
|
System.UInt16 ushort
|
0 to 65535
|
|
System.UInt32 uint
|
0 to 4,294,967,295
|
|
System.Int64 long
|
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
|
|
System.UInt64 ulong
|
0 to 18,446,744,073,709,551,6157
|
|
System.Char char
|
0 to 65535
|
|
Description
|
Regular Expression
|
|
Alphanumerics,-, +, . , and whitespace
|
^([\w\.+-]|\s)*$
|
|
Alphanumerics,-, +, . , and whitespace with a defined range. Replace nMin,nMax with
the minimum (i.e 1) and maximum length (i.e 5) for the range. This would check for
length of 1 to 5 as well as the described character match
|
^([ \w\. +-] | \s){nMin, nMax}$
|
|
A Person's Name
|
^[a-zA-Z\' \-\s]{nMin, nMax}$
|
|
MM/DD/YYYY - Accepts one or two digits for Month/Day and two or four digits for
the year
|
^\d{1,2}\/\d{1,2}\/\d{2,4}$
|
|
MM/DD/YY
|
^\d{1,2}\/\d{1,2}\/\d{2,2}$
|
|
Time with optional am/pm
|
^\d{1,2}:\d{2}\s?([ap]m)?$
|
|
5 Digit Zip
|
^\d{5}?$
|
|
5 Digit Zip With Optional extension
|
^\d{5}(-\d{4})?$
|
|
IP Address
|
^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$
|
|
Email Address that does not accept IPs
|
^[A-Za-z0-9_\-\.]+@(([A-Za-z0-9\-])+\.)+([A-Za-z\-])+$
|
|
Money
|
^\$?[+-]?[\d,]*\.?\d{0, 2}$
|
|
Credit Card (4 x 4) with optional - or spaces. It doesn't not validate that the
credit card is a valid number, it only checks that the credit card number looks
right. Validate Credit Card Numbers in C#
|
^((\d{4}[-]?){3}\d{4})$
|
|
Social Security
|
^\d{3}-\d{2}-\d{4}$
|
State/Possession Abbreviation
ALABAMA AL
ALASKA AK
AMERICAN SAMOA AS
ARIZONA AZ
ARKANSAS AR
CALIFORNIA CA
COLORADO CO
CONNECTICUT CT
DELAWARE DE
DISTRICT OF COLUMBIA DC
FEDERATED STATES OF MICRONESIA FM
FLORIDA FL
GEORGIA GA
GUAM GU
HAWAII HI
IDAHO ID
ILLINOIS IL
INDIANA IN
IOWA IA
KANSAS KS
KENTUCKY KY
LOUISIANA LA
MAINE ME
MARSHALL ISLANDS MH
MARYLAND MD
MASSACHUSETTS MA
MICHIGAN MI
MINNESOTA MN
MISSISSIPPI MS
MISSOURI MO
MONTANA MT
NEBRASKA NE
NEVADA NV
NEW HAMPSHIRE NH
NEW JERSEY NJ
NEW MEXICO NM
NEW YORK NY
NORTH CAROLINA NC
NORTH DAKOTA ND
NORTHERN MARIANA ISLANDS MP
OHIO OH
OKLAHOMA OK
OREGON OR
PALAU PW
PENNSYLVANIA PA
PUERTO RICO PR
RHODE ISLAND RI
SOUTH CAROLINA SC
SOUTH DAKOTA SD
TENNESSEE TN
TEXAS TX
UTAH UT
VERMONT VT
VIRGIN ISLANDS VI
VIRGINIA VA
WASHINGTON WA
WEST VIRGINIA WV
WISCONSIN WI
WYOMING WY
Military "State" Abbreviation
Armed Forces Africa AE
Armed Forces Americas AA
(except Canada)
Armed Forces Canada AE
Armed Forces Europe AE
Armed Forces Middle East AE
Armed Forces Pacific AP