stefankueng / grepWin

A powerful and fast search tool using regular expressions
https://tools.stefankueng.com/grepWin.html
GNU General Public License v3.0
1.72k stars 179 forks source link

Feature request: multiple matches of capture group per line #473

Open PavloMa opened 3 months ago

PavloMa commented 3 months ago

Thank you very much for the useful tool.

There is a newer future in grepWin, allowing to list the contents of groups captured during search. You get it by entering, e.g., $1 into "Replace with/capture format" input box and click "Search/Capture search" button.

It works good, but provides only one result per group, although there can be multiple matches per line.

It would be nice, if grepWin could capture and list multiple matches. It requires, as far as I can judge, access to "g" (global) switch of grep. This is discussed in detail here https://stackoverflow.com/questions/37003623/how-to-capture-multiple-repeated-groups

My simple task is the following: I want to capture prepositions occurring in each line with the following GREP: (?:(?<![äöüÄÖÜß\w])(an|auf|um|über|von|vor|ins|ans|mit|daran|darauf|dafür|Wovon|Woraus|davon|Darüber|zueinander|in|für|nach|Für|zu|woran|gegen|dabei|bei|In|am|zur|davor|zum|Woran|darüber|Über|danach|Mit|voneinander|Aus|dagegen|damit|seit|Daraus|aus|gegeneinander|darum|im|wofür|dazu|Wonach|Dagegen)(?![äöüÄÖÜß\w]))+ For example: Input Ich wundere mich immer wieder über dich. Diese Text wurde aus dem englischlichen ins Deutsch übersetzt. Output über aus ins

Thank you!

stefankueng commented 2 months ago

The "capture search" lists

über
aus
ins

as separate matches, but the last two with the same line number. Isn't that enough? What more do you need?