开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜