public static boolean isPrime(int n) {
return !new String(new char[n]).matches(".?|(..+?)\\1+");
}
https://stackoverflow.com/posts/4515687/revisions
What is this doing in detail?
Is ".?|(..+?)\\1+"
equal to ".?"
?
( I'm practising regex from this website http://regex101.com/r/jL7qD4 )