m-ender / retina

A regex-based programming language.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiline match — individual output per line

Sp3000 opened this issue · comments

Would be good to have a mode which prints the number of matches, one per line, for each line in the input. For example:

Regex:

[a-e]

Input:

abcde
a
xyz

Output:

5
1
0

I'm thinking I'll implement this as an option to go with any mode. Doesn't make much sense for grep mode maybe, but in general I think it could be really useful (this would also allow entire loops to be applied to each line separately).

Implemented in 30b3c38, currently using % for the option. I might change this to : if I figure out a consistent way to reduce the :\; set to just \;. I should also look into how I can allow people to specify other "line separators" than \n.