Regex that finds and replaces within YAML frontmatter? AI can't solve it, been haunting me for days

How many instances of amazon-url and wikipedia-url do you have outside of properties? It may be easier to temporarily change them to something else so you can run a regex that doesn’t try to match only within properties, like

^(amazon-url|wikipedia-url)(?=:)

(which matches either of the strings if it begins at the start of a line and is followed by a colon).

Otherwise I think you’ll be trying to do a multiline lookahead and a multiline lookbehind, which besides being potentially tricky to figure out (certainly painful to read) may end up freezing Obsidian.

Also, I edited the original post to mark the code as code.

2 Likes