Zeichen | Bedeutung | Beispiel | Ergebnis |
---|---|---|---|
[a,b,c] | a oder b oder c | 'a'.matches('[a,b,c]') 'b'.matches('[a,b,c]') 'B'.matches('[a,b,c]') |
true true false |
[^a,b,c] | weder a noch b noch c | 'a'.matches('[^a,b,c]') 'b'.matches('[^a,b,c]') 'B'.matches('[^a,b,c]') |
false false true |
[a-z] | alle Zeichen von a bis z | 'a'.matches('[a-z]') 'x'.matches('[a-z]') 'B'.matches('[a-z]') |
true true false |
[a-zA-Z] | alle Zeichen von a bis z oder von A bis Z | 'a'.matches('[a-zA-Z]') 'x'.matches('[a-zA-Z]') 'B'.matches('[a-zA-Z]') |
true true true |
[a-d[x-z]] | alle Zeichen von a bis d oder von x bis z | 'a'.matches('[a-d[x-z]]') 'x'.matches('[a-d[x-z]]') 'B'.matches('[a-d[x-z]]') |
true true false |
[a-z&&[^bp]] | alle Zeichen von a bis z außer b oder p | 'a'.matches('[a-z&&[^bp]]') 'x'.matches('[a-z&&[^bp]]') 'p'.matches('[a-z&&[^bp]]') |
true true false |