I have 3 values IU, PRI and RET. if my input string contains any one or more value(s), the Java regular expression should return true.
You need word boundaries for that:
boolean foundMatch = false; Pattern regex = Pattern.compile("\\b(?:UI|PRI|RET)\\b"); Matcher regexMatcher = regex.matcher(subjectString); foundMatch = regexMatcher.find();