Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. void main() {
  2. // O caractere '^' checa se a frase começa com algum caractere dentro do conjunto
  3. // Os colchetes denominam um conjunto (como esse só tem '\d' não é realmente necessário)
  4. // '\d' checa por digitos, é intercambiável com "0-9"
  5. // O caractere '+' mais checar se existe mais ou uma ocorrencia dos itens do conjunto
  6. // E o caractere '$' checa se a frase termina com um dos itens.
  7. RegExp exp = new RegExp(r"(^[\d]+$)");
  8.  
  9. String teste1 = "12345";
  10. String teste2 = "teste1234";
  11.  
  12. bool ehValido1 = exp.hasMatch(teste1);
  13. print("Teste 1: " + ehValido1.toString());
  14.  
  15. bool ehValido2 = exp.hasMatch(teste2);
  16. print("Teste 2: " + ehValido2.toString());
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement