What does the metacharacter, '?' match?
I researched and i know that the '?' is used t开发者_JAVA百科o match if the result occurs 0 or 1 times in a matching function. Unfortunately, i cannot find a clear example on what exactly does '?' matches.
Cheers.
Regular expression
co?at
Would match coat
and cat
?
itself doesn't match anything. It's just a modifier that modifies the preceding atom (e.g. character or group). It does what you say: The preceding atom must appear 0 or 1 times in order for the regex to match.
精彩评论