fork(1) download
  1. import java.util.Arrays;
  2. import java.util.regex.Pattern;
  3.  
  4. class Main {
  5. public static void main(String[] args) {
  6. String[] arr = { "card", "creditcard", "debitcard" };
  7. String inputStr = "You need to discard Pin Card.";
  8.  
  9. boolean result = Arrays.stream(arr)
  10. .anyMatch(word -> Pattern
  11. .compile("(?<![a-z-])" + Pattern.quote(word) + "(?![a-z-])", Pattern.CASE_INSENSITIVE)
  12. .matcher(inputStr)
  13. .find());
  14. System.out.println(result);
  15. }
  16. }
Success #stdin #stdout 0.11s 50932KB
stdin
Standard input is empty
stdout
true