Overview
| Artifact ID: | ab9de3745c770a76e93189c62007c6ef5afddebc |
|---|---|
| Ticket: | 700ac47ece488c90836eac2e459ad29e6f329b6e
Bug in regexp matching |
| User & Date: | ysch on 2014-12-29 21:43:14 |
Changes
- icomment:
> Hi, I have seen a bug in regexp matching. No, you didn't. ;) > I verified VS external regexp engines that indeed im not mistaken. Other engines are irrelevant here. From man re_syntax: --- In the event that an RE could match more than one substring of a given string, the RE matches the one starting earliest in the string. If the RE could match more than one substring starting at that point, its choice is determined by its preference: either the longest substring, or the shortest. Most atoms, and all constraints, have no preference. A parenthesized RE has the same preference (possibly none) as the RE. A quantified atom with quantifier {m} or {m}? has the same preference (possibly none) as the atom itself. A quantified atom with other normal quantifiers (including {m,n} with m equal to n) prefers longest match. A quantified atom with other non-greedy quantifiers (including {m,n}? with m equal to n) prefers shortest match. A branch has the same preference as the first quantified atom in it which has a preference. --- Your RE starts with quantified atom with normal quantifier (\n?), so this atom prefers longest match. As your RE consists of single branch, "it has the same preference as the first quantified atom in it which has a preference" --- longest match. So, it's not a bug. So, your RE should have been: \n??(0+?) - login: "ysch"
- mimetype: "text/plain"