Remnote multiline style regex for Obsidian to Anki plugin

After struggling for an hour with no prior knowledge of regex, I’ve finally managed to create a regex suitable for my workflow with Obsidian_to_Anki (Obsidan to Anki) plugin. This is basically a Remnote style with multiline support (multiple lines are captured). Previous line, Next line after 2 line breaks, and Obsidian ID line are not captured. I want to share my finding, hopefully it will be useful for those having similar preference

Regex: ((?:[^\n]?)+) ::((?:.|\n(?:^.{1,3}$|^.{4}(?<!<!--).*))+)

Test link: regex101: build, test, and debug regex

1 Like

Update:

I’ve managed to shorten the code, and also create another version specifically for supporting bulleted list only (ignore normal multiline text)

Support multiline:
Regex: (.+) ::((?:.|\n.{4}(?<!<!--))+)
Test link: regex101: build, test, and debug regex

Support list only:
Regex: (.+) ::((?:.|\n.{4}(?<!<!--|[^-\d]...))+)
Test link: regex101: build, test, and debug regex

1 Like