fork(19) download
  1. import java.util.regex.Matcher;
  2. import java.util.regex.Pattern;
  3.  
  4. class Ideone
  5. {
  6. public static void main(String[] args) {
  7. String haystack[] = {"Ahmet Yıldırım", "Esin AYDEMİR"};
  8. String needle[] = {"yildirim", "aydemir"};
  9. for (int i = 0; i < haystack.length; i++) {
  10. System.out.println(find(haystack[i], needle[i]));
  11. }
  12.  
  13. }
  14.  
  15. public static boolean find(String haystack, String needle) {
  16. Pattern p = Pattern.compile(needle, Pattern.LITERAL | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
  17. Matcher m = p.matcher(haystack);
  18. if (m.find()) {
  19. System.out.println(m.group());
  20. return true;
  21. } else {
  22. return false;
  23. }
  24.  
  25. }
  26. }
  27.  
Success #stdin #stdout 0.11s 320512KB
stdin
Standard input is empty
stdout
Yıldırım
true
AYDEMİR
true