Skip to content

Instantly share code, notes, and snippets.

@Aleyasen
Created February 4, 2016 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aleyasen/cbec46cd4cd6b05929e2 to your computer and use it in GitHub Desktop.
Save Aleyasen/cbec46cd4cd6b05929e2 to your computer and use it in GitHub Desktop.
static String patternString[][] = {
{"singleCapLetterWithDot", "[A-Z]\\."},
{"singleCapLetter", "[A-Z]"},
// {"isInitCapital", "[A-Z][a-z]+"},
{"isAllCapital", "[A-Z]+"},
// {"isAllSmallCase", "[a-z]+"},
{"singleDot", "[.]"},
{"singleComma", "[,]"},
{"singleQuote", "[']"},
{"isSpecialCharacter", "[#;:\\-/<>'\"()&]"},
//{"isWord", "[a-zA-Z][a-zA-Z]+" },
//{"isAlpha", "[a-zA-Z]+" },
//{"isAlphaNumeric", "[a-zA-Z0-9]+" },
{"money", "\\$(\\d{1,3}(\\,\\d{3})*|(\\d+))(\\.\\d{2})?"},
{"date", "((((0[13578])|([13578])|(1[02]))[\\/](([1-9])|([0-2][0-9])|(3[01])))|(((0[469])|([469])|(11))[\\/](([1-9])|([0-2][0-9])|(30)))|((2|02)[\\/](([1-9])|([0-2][0-9]))))[\\/]\\d{4}$|^\\d{4}"},
{"singleDigit", "\\d"},
{"twoDigits", "\\d{2}"},
{"threeDigits", "\\d{3}"},
{"fourDigits", "\\d{4}"},
{"isDigits", "\\d+"},
{"containsDigit", ".*\\d+.*"},
{"isNumberRange", "\\d+\\s*([-]{1,2}\\s*\\d+)?"},
{"endsWithDot", "\\p{Alnum}+\\."},
{"endsWithComma", "\\w+[,]"},
{"endsWithPunctuation", "\\w+[;:,.?!]"},
{"singlePunctuation", "\\p{Punct}"},
{"singleAmp", "[&]"},
{"isDashSeparatedWords", "(\\w[-])+\\w"},
{"isDashSeparatedSeq", "((\\p{Alpha}+|\\p{Digit}+)[-])+(\\p{Alpha}+|\\p{Digit}+)"},
{"isURL", "\\p{Alpha}+://(\\w+\\.)\\w+(:(\\d{2}|\\d{4}))?(/\\w+)*(/|(/\\w+\\.\\w+))?"},
{"isEmailId", "\\w+@(\\w+\\.)+\\w+"},
{"containsDashes", ".*--.*"},
{"containsSpecialCharacters", ".*[#;:\\-/<>'\"()&].*"},};
// we compile "(?<!\\S)" + patternString[i][1] + "(?!\\S)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment