Timeline for Is there a way to select the shortest match on alternation?
Current License: CC BY-SA 4.0
Post Revisions
12 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 13, 2020 at 0:08 | answer | added | user232326 | timeline score: 1 | |
| Apr 12, 2020 at 22:50 | history | edited | user232326 | CC BY-SA 4.0 |
deleted 128 characters in body
|
| Apr 11, 2020 at 23:28 | history | edited | user232326 | CC BY-SA 4.0 |
added 282 characters in body
|
| Apr 11, 2020 at 22:06 | comment | added | user232326 | @mosvy (1) Also: Traditional NFA engines run so-called "greedy" match backtracking algorithms, testing all possible expansions of a regular expression in a specific order and accepting the first match. Note the word first.link | |
| Apr 11, 2020 at 21:44 | history | edited | user232326 | CC BY-SA 4.0 |
added 18 characters in body
|
| Apr 11, 2020 at 21:40 | comment | added | user232326 | @mosvy (1) Fact When you use a Tradition NFA engine, the order of the alternative in an alternation will be respected. This means that if the first alternative lead to a complete successful match, the other alternative will be ignored. Link | |
| Apr 11, 2020 at 20:55 | answer | added | q.undertow | timeline score: 4 | |
| Apr 11, 2020 at 20:50 | history | edited | user232326 | CC BY-SA 4.0 |
Possible answer(s) thanks @StéphaneChazelas
|
| Apr 11, 2020 at 20:43 | comment | added | Stéphane Chazelas |
It's a POSIX requirement that the longest match be found for BRE and ERE. You can use perl or grep -P (when that's implemented with PCRE like with GNU grep, not ast-open's) for the other alternations not to be considered if a one further on the left matched.
|
|
| Apr 11, 2020 at 20:29 | history | edited | user232326 | CC BY-SA 4.0 |
added 47 characters in body
|
| Apr 11, 2020 at 20:07 | history | edited | user232326 | CC BY-SA 4.0 |
added 30 characters in body
|
| Apr 11, 2020 at 19:48 | history | asked | user232326 | CC BY-SA 4.0 |