Zeichen | Bedeutung | Beispiel | Ergebnis |
---|---|---|---|
? | genau einmal | 'a' matches ('a?') 'aa' matches ('a?') |
true false |
+ | ein oder mehrmals | 'a' matches ('a+') 'aa' matches ('a+') '' matches ('a+') |
true true false |
* | 0 oder ein oder mehrmals | 'aa'.matches('a*') ''.matches('a*') |
true true |
{n} | genau n-mal | 'aaa'.matches('a{3}') 'aaa'.matches('a{2}') |
true false |
{n,} | mindestens n-mal | 'aaa'.matches('a{2,}') | true |
{n,m} | mindestens n-mal und maximal m-mal | 'a'.matches('a{1,2}') 'aa'.matches('a{1,2}') 'aaa'.matches('a{1,2}') |
true true false |