Expressão Regular para validar Letras [RESOLVIDO]  XML
Índice dos Fóruns » Java Básico
Autor Mensagem
Metaleiro
Virtual Machine Man
[Avatar]

Membro desde: 06/07/2006 10:55:54
Mensagens: 671
Localização: São Bernardo do Campo - SP
Offline

Estou tentando criar uma expressão regular para validar se existe 3 letras(somente) em uma String, alguém poderia me ajudar ?


Desde já agradeço !


This message was edited 1 time. Last update was at 05/04/2011 13:01:06


"Why, Mr. Anderson? Why do you do it? Why get up? Why keep fighting? Do you believe you're fighting for something? For more than your survival? Can you tell me what it is? Do you even know? Is it freedom? Or truth? Perhaps peace? Yes? No? Could it be for love? Illusions, Mr. Anderson. Vagaries of perception. The temporary constructs of a feeble human intellect trying desperately to justify an existence that is without meaning or purpose. And all of them as artificial as the Matrix itself, although only a human mind could invent something as insipid as love. You must be able to see it, Mr. Anderson. You must know it by now. You can?t win. It?s pointless to keep fighting. Why, Mr. Anderson? Why? Why do you persist?"

Neo :
-Because is my choice

Schuenemann
GUJ Ranger

Membro desde: 13/01/2005 12:31:27
Mensagens: 854
Offline

^[a-zA-Z]{3}$

This message was edited 1 time. Last update was at 05/04/2011 12:19:19

Metaleiro
Virtual Machine Man
[Avatar]

Membro desde: 06/07/2006 10:55:54
Mensagens: 671
Localização: São Bernardo do Campo - SP
Offline

Schuenemann wrote:^[a-zA-Z]{3}$


Obrigado pela ajuda, depois descobri que o que eu precisava era apenas contar 3 letras em uma String e validar, vou deixar aqui as duas soluções, obrigado:






"Why, Mr. Anderson? Why do you do it? Why get up? Why keep fighting? Do you believe you're fighting for something? For more than your survival? Can you tell me what it is? Do you even know? Is it freedom? Or truth? Perhaps peace? Yes? No? Could it be for love? Illusions, Mr. Anderson. Vagaries of perception. The temporary constructs of a feeble human intellect trying desperately to justify an existence that is without meaning or purpose. And all of them as artificial as the Matrix itself, although only a human mind could invent something as insipid as love. You must be able to see it, Mr. Anderson. You must know it by now. You can?t win. It?s pointless to keep fighting. Why, Mr. Anderson? Why? Why do you persist?"

Neo :
-Because is my choice

Schuenemann
GUJ Ranger

Membro desde: 13/01/2005 12:31:27
Mensagens: 854
Offline


Isso só testa se em algum ponto da string tem isso.
"3aaa %e" passa nesse seu teste .

E no for use Character.isLetter() e demais métodos dessa classe.

This message was edited 1 time. Last update was at 05/04/2011 13:08:37

Metaleiro
Virtual Machine Man
[Avatar]

Membro desde: 06/07/2006 10:55:54
Mensagens: 671
Localização: São Bernardo do Campo - SP
Offline

Schuenemann wrote:
Isso só testa se em algum ponto da string tem isso.
"3aaa %e" passa nesse seu teste .

E no for use Character.isLetter() e demais métodos dessa classe.


Funcionou legal, obrigado





This message was edited 1 time. Last update was at 07/04/2011 11:26:05


"Why, Mr. Anderson? Why do you do it? Why get up? Why keep fighting? Do you believe you're fighting for something? For more than your survival? Can you tell me what it is? Do you even know? Is it freedom? Or truth? Perhaps peace? Yes? No? Could it be for love? Illusions, Mr. Anderson. Vagaries of perception. The temporary constructs of a feeble human intellect trying desperately to justify an existence that is without meaning or purpose. And all of them as artificial as the Matrix itself, although only a human mind could invent something as insipid as love. You must be able to see it, Mr. Anderson. You must know it by now. You can?t win. It?s pointless to keep fighting. Why, Mr. Anderson? Why? Why do you persist?"

Neo :
-Because is my choice

 
Índice dos Fóruns » Java Básico
Ir para:   
Powered by JForum 2.1.8 © JForum Team