/* package whatever; // don't place package name! */
import java.util.* ;
import java.lang.* ;
import java.io.* ;
import java.util.regex.Pattern ;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
/** validação */
public static final String REGEX
= "^[A-Z|a-z|0-9| |Á-Ú|á-ú|Ã-Ũ|ã-ũ|'|-]+$" ; public static final Pattern pattern = Pattern.compile ( REGEX) ;
/** testes positivos */
public static String [ ] itens
= { "á é í ó ú" ,
"ã ẽ ĩ õ ũ" ,
"Á È Ĩ Ã ó" ,
"aeiou" ,
"abc def ghi" ,
"um 23 45" ,
"Um - 2 - tres quatro" , "Um' 2 três' quatro" , "maçã" , "Â Ê Î ô û" , "á Ae Éi Ĩô O" } ;
boolean b = isValid( s) ;
System .
out .
println ( b
+ " : " + s
) ; }
}
public static boolean isValid
( final String string
) { return pattern.matcher ( string) .matches ( ) ;
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnV0aWwucmVnZXguUGF0dGVybjsKCgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCS8qKiB2YWxpZGHDp8OjbyAqLwoJcHVibGljIHN0YXRpYyBmaW5hbCBTdHJpbmcgUkVHRVg9ICJeW0EtWnxhLXp8MC05fCB8w4Etw5p8w6Etw7p8w4Mtxah8w6Mtxal8J3wtXSskIjsKCXB1YmxpYyBzdGF0aWMgZmluYWwgUGF0dGVybiBwYXR0ZXJuID0gUGF0dGVybi5jb21waWxlKFJFR0VYKTsKCS8qKiB0ZXN0ZXMgcG9zaXRpdm9zICovCglwdWJsaWMgc3RhdGljIFN0cmluZ1tdIGl0ZW5zID0geyAiw6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