You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Utils.java 629B

123456789101112131415161718192021222324
  1. package com.rthoni.stssaguenay.business;
  2. import java.text.Normalizer;
  3. /**
  4. * Created by robin on 9/29/16.
  5. */
  6. public class Utils {
  7. public static String unaccent(String s) {
  8. String normalized = Normalizer.normalize(s, Normalizer.Form.NFD);
  9. return normalized.replaceAll("[^\\p{ASCII}]", "");
  10. }
  11. public static String normalizeString(String str)
  12. {
  13. return unaccent(str).toLowerCase().replaceAll("[^a-z0-9]", " ").replaceAll(" +", " ");
  14. }
  15. public static boolean stringMatch(String str1, String str2)
  16. {
  17. return normalizeString(str1).contains(normalizeString(str2));
  18. }
  19. }