Replace all values between two specified characters

Whenever i copy a mathematical formula from a document online, instead of the LaTex syntax, i get this instead:
![d = r_1- r_2] (
The image that the obsidian shows itself isn’t bad, but i’d still prefer to have the LaTex being built by obisidian itself. Removing it manually seems like the most obvious approach, but there are dozens of documents each with tens of those links, so i’d like to make this as automatic as possible
Luckily i don’t happen to have any other internal links on the documents, so i can replace all [] with $$ and remove all “!”, which in turn creates the LaTex formulas on obsidian. But that still leave the image links. Each of them are different so removing them all in bulk like this isn’t possible. But the thing is, each link is placed between (). See where i’m getting at?
I was wondering if it was possible to remove everything that is located between inside a paranthesis, or between any 2 specified characters here on obisidian. Is there a plugin or a functionality like that on obsidian?

If you enable VIM keybindings, di( deletes everything inside a set of parentheses. It is a manual method, but it can go pretty quick.

Honestly i’m very confused. I experimented VIM keybendings and i learned the basic of navigations with it and all, but what is this di(? Can you explain in more detail which keyword you have to press in order to activate this mode or command?

In normal mode, place the cursor inside a pair of parentheses and press di( and it will delete everything inside of the parentheses. The following are some other commands you could use including di(

d{motion} – Delete text that {motion} moves over.
di( – Delete text inside parentheses.
da( – Delete text and parentheses.

It is possible with RegEx. Obsidian supports searching with RegEx but no replacement.
But you could do it with any of the usual Editors like VSC, Atom, …

Two examples

  • With a Subpattern (always supported)

    • Match: (\]\()[^)]+ => !\[...*](...*)

    • Replace: $1 => !\[...*](*)

  • With a Lookbehind (if supported, maybe expensive/slow)

    • Match: (?<=\]\()[^)]+ => !\[...](*...*)

    • Replace: empty string => !\[...](**)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.