String (String regexp, int group, String suffix, String ignoreValue) { if (myText == null) { return ""; } Matcher matcher = Pattern.compile(".*" + regexp + ".*", Pattern.DOTALL | Pattern.MULTILINE).matcher(myText); if (matcher.matches()) { String date = matcher.group(group); if (!StringUtil.isEmpty(date) && !date.equals(ignoreValue)) { return date + suffix; } } return ""; }