Last active
August 29, 2015 13:56
-
-
Save Xerosigma/8979693 to your computer and use it in GitHub Desktop.
Regex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Five or nine digit U.S. zipcodes. | |
public static final String REGEX_ZIP = "[^\\d{5}([\\-]?\\d{4})?$]"; | |
// Dates: 12/31/2014 | |
public static final String REGEX_DATE = "^(0[1-9]|1[012])[- \\/.](0[1-9]|[12][0-9]|3[01])[- \\/.](19|20)\\d\\d$"; | |
// Dates: 2014/12/31 | |
public static final String REGEX_DATE_DATA = "^(19|20)\\d\\d[- \\/.](0[1-9]|1[012])[- \\/.](0[1-9]|[12][0-9]|3[01])$"; | |
// Integers | |
public static final String REGEX_INT = "^[0-9]+$"; | |
// Integers or floats with max precision of two. | |
public static final String REGEX_INT_FLOAT = "^(\d+)?(\.\d{1,2})?$"; | |
// Floats with max precision of two. | |
public static final String REGEX_FLOAT = "^(\d+)?\.\d{1,2}$"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment