Go to the first, previous, next, last section, table of contents.


Repeated Subexpressions

* is the repeat operator. It applies to the preceeding character, character set, subexpression or backreference. It indicates that the preceeding element can be matched 0 or more times:

bana\(na\)*

matches

bana
banana
bananana
banananana
...

\+ is similar to * except that \+ requires the preceeding element to be matched at least once. So while:

bana\(na\)*

matches

bana
bana(na\)\+

does not. Both match

banana
bananana
banananana
...

Thus, bana\(na\)+ is short-hand for banana\(na\)*.


Go to the first, previous, next, last section, table of contents.