Timeline for How to highlight the matched regex pattern got by many regex exps disjoined with `||` in awk?
Current License: CC BY-SA 4.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 30, 2024 at 1:45 | comment | added | An5Drama |
Complement for 1: gsub mentioned by Ed Morton will work for the case where "TODO" occurs more than once which is explicitly shown by the edit of Stéphane Chazelas's answer.
|
|
| Dec 29, 2024 at 13:41 | comment | added | An5Drama |
1. Here sub is same as match to return the "leftmost" substring. Anyway this is enough for my situation since my search pattern "TODO" can at most exist once in one line. 1.a. So maybe Kusalananda's workaround is better and more general (similar for Stéphane Chazelas's). But anyway this answer replies to my question about awk more appropriately.
|
|
| Dec 29, 2024 at 11:22 | comment | added | An5Drama | Thanks. I use the solution in your last line since that has almost the same structure as the original. Anyway the ideas are similar among your solutions. | |
| Dec 29, 2024 at 11:21 | vote | accept | An5Drama | ||
| Dec 29, 2024 at 10:38 | comment | added | Ed Morton |
sub() and gsub() will work in any awk, it's gensub() that'll only work in GNU awk (and 1 or 2 others).
|
|
| Dec 29, 2024 at 9:48 | history | answered | meuh | CC BY-SA 4.0 |