Sregx: A tool using structural regular expressions

Grep like CLI that utilizes structural regular expressions. They should feel familiar to Kakoune (and Vis) users.

Let’s see an example: given a markdown file, list all headers, but ignore # in code blocks.

Kakoune filter:

kak -f 's```.+?```<ret>d%<a-s><a-K>^#+ <ret>d' < input

sregx

sregx "x/(?s)```.*?```/d | x/.*\n/ g/^#+\s(.+)/p" < input

The commands map almost 1:1. Pretty interesting.

1 Like