(I’m writing a shortcut to update a list of calendar events in a note, in the H2 section “Events”, which always comes before the H2 section “Plans”.)
Any ideas as to what I’m doing wrong? Thanks for any help anyone might supply.
Welcome to the forum, @consequently! Apple doesn’t use JS-style regular expressions. Assuming your note looks like this:
## Events whatever
My guess is you want to replace the two headlines with either nothing or something completely different, effectively remove them? Your regex doesn’t have any captures, so your replacement doesn’t know about anything found in the search pattern. If so, this is the regex you’re looking for:
I’ve made your regex a bit less strict. \s means “one whitespace here”, where whitespace is a space or tab etc., while \s+ means “one or more whitespace here” which makes it work even if for some reason there are two spaces after ##.
Now I have a little shortcut that I can launch from Obsidian itself (either on iOS or the Mac) which populates my daily note with a list of events for the day—and which can repopulate the list (overwriting the old one) if needed.