문제

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).

도움이 되었습니까?

해결책

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...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top