/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
String line
= "aluno/1/Teste dos Testes/1,2,33,3,4"; String line2
= "aluno/1/Teste dos Testes/1,2,33,3,4a"; String line3
= "aluno/1/Teste dos Testes/1,2,33,3,a"; String line4
= "aluno/1/Teste dos Testes/1,2,33a,3"; String pattern
= "(\\/[\\d,]+\\d)$";
Pattern r = Pattern.compile(pattern);
Matcher i = r.matcher(line);
Matcher i2 = r.matcher(line2);
Matcher i3 = r.matcher(line3);
Matcher i4 = r.matcher(line4);
if (i.find( )) {
System.
out.
println("Valor encontrado: " + i.
group(0) ); }else{
System.
out.
println("Inválido"); }
if (i2.find( )) {
}else{
System.
out.
println("Inválido"); }
if (i3.find( )) {
}else{
System.
out.
println("Inválido"); }
if (i4.find( )) {
}else{
System.
out.
println("Inválido"); }
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnV0aWwucmVnZXguTWF0Y2hlcjsKaW1wb3J0IGphdmEudXRpbC5yZWdleC5QYXR0ZXJuOwoKLyogTmFtZSBvZiB0aGUgY2xhc3MgaGFzIHRvIGJlICJNYWluIiBvbmx5IGlmIHRoZSBjbGFzcyBpcyBwdWJsaWMuICovCmNsYXNzIElkZW9uZQp7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykgdGhyb3dzIGphdmEubGFuZy5FeGNlcHRpb24KCXsKCQlTdHJpbmcgbGluZSA9ICJhbHVuby8xL1Rlc3RlIGRvcyBUZXN0ZXMvMSwyLDMzLDMsNCI7CgkJU3RyaW5nIGxpbmUyID0gImFsdW5vLzEvVGVzd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