I just got this:
System.out.println("КОНТАКТЫ".matches("(?i).*контакт.*"));
and it always says "false".
I tried:
System.out.println("КОНТАКТЫ".matches("(?i:.*контакт.*)"));
and:
System.out.println("КОНТАКТЫ".matches("(?i:).*контакт.*"));
and:
System.out.println("КОНТАКТЫ".matches("(?i)^.*контакт.*$"));
and many others variations but I always have "false".
How to perform case insensitive search in java correctly so I have "true" in this regexp search?
What do I do wrong?
What you need is to turn unicode case flag on:
System.out.println("КОНТАКТЫ".matches("(?iu).*контакт.*"));
More here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With