Import files from ConnectedText - help with regex

What I’m trying to do

I’m trying to find out if it is possible to convert the ‘categories’ produced in .txt note exports from the old app ConnectedText to Obsidian ‘tag’ formatting.

I need to change lines that look like the following;

[[$CATEGORY:apples|oranges|orangutans]]

Into obsidian syntax, i.e.;

#apples
#oranges
#orangutans

I’m assuming I need to use some kind of batch regex find and replace on all the files, but I don’t know how to do it. Can anyone help? Or is there a better way?

Things I have tried

I’ve searched the forums and can see that several former ConnectedText users have imported their notes into Obsidian, but I can’t find any info about how they have done it.

I think I have managed to work this out. My approach;

First, run a regex find and replace with the following terms

Find:

(^[[$CATEGORY:)(.+)(]]$)

Replace:

|$2

This turns

[[$CATEGORY:apples|oranges|orangutans]]

into

|apples|oranges|orangutans

It is then possible to run a normal find and replace, to turn all the pipes into a space followed by a hashtag.

Happily, ConnectedText has a global find and replace function within the software, so I think I should be sorted.