Example:
/(?:Foo){0}bar/
I saw something like this in another answer. At first I thought \"what should that be\", but then, \"OK could make sense, kind of a
There are good uses of {0}
. It allows you to define groups that you don't intend to capture at the moment. This can be useful in some cases:
The best one - use of the group in recursive regular expressions (or other weird constructs). Perl, for example, has (?(DEFINE) ) for the same use.
A quick example - in PHP, this will match barFoo
(working example):
preg_match("/(?:(Foo)){0}bar(?1)/", "barFoo", $matches);
Adding a failed captured group (named or numbered) to the result matches.
Less good uses, as Peter suggested are useful in:
{0}
and {1}
may lead thinking in the right direction. (OK, not the best point)These are all rare cases, and in most patterns it is a mistake.