public static Pattern createRegExPatternIfValid ( String _regExStr ) { if ( StringUtil . isBlank ( _regExStr ) ) { return null ; } Pattern pattern ; try { pattern = Pattern . compile ( _regExStr ) ; } catch ( PatternSyntaxException _ex ) { return null ; } return pattern ; }
Creates a RegEx Pattern object if given String is a valid regular expression .