Pergunta

I know that for sure that a text has not digit, We can do simple this work:

text.matches(".*\\d.*"));     // if return true, then text has digit

Now, how determine a character in user input?

I need to determine character in user typed input by regular expression (because it is simpler that other functions).

Foi útil?

Solução

You can use a character set like: [a-zA-Z]+ to match one or more letters of A-Z ignoring case.

You could use \w to match all "word characters" which includes [a-zA-Z_0-9]

Or, if you want to match any character that isn't a space, you could use \S.

It depends on how you define a "character" in user input...

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top