1

if someone could help me with my regex-problem, it would be aweful !

I have an EditText and the charakters which are allowed to be typed in are the following:

A-Z, Ä, Ö, Ü (only uppercases), and ß

I'm grateful for any help!

2 Answers2

1

Use [A-ZÄÖÜß]+ as your regular expression.

Replace + with * if you want to support zero length strings.

(You might want to use \u notation in your source code in place of the special characters to help code editors and source control systems.)

Bathsheba
  • 227,678
  • 33
  • 352
  • 470
1

You mean something like this?

Pattern p = Pattern.compile("^[A-ZÄÖÜß]+$");
Matcher m = p.matcher(inputString);
if(m.matches() {
    //Do whatever you need to do when the pattern matches.
}
npinti
  • 51,070
  • 5
  • 71
  • 94