regexmarkdownpairwise

How to deal with matches pairwise in regex?


I have a basic understanding of regex (I think) - but lookahead and all that just escapes me :( So I have a sense that this should be doable with rx, but I have no idea how to do it.

I want to copy Markdown from Notion into MediaWiki. Both support MD - but different flavours. So I thought I could do some search & replace in a text editor to deal with the differences.

But: strikeout text is "~~text~~" in Notion and "<s>text</s>" in MediaWiki.


Solution

  • Interesting how one can think overly complex. It suddenly hit me that I don't have to worry about counting or doing advanced stuff looking at individual occurences of ~~, but that I could look at the paired case using a search string "~~(.*?)~~" and a replacement "<s>$1</s>".

    Nice & easy 😉