Search And Replace In Periodic Note
"Periodic Note" is a collective term for Daily, Weekly, Monthly, Quarterly and Yearly Notes. In v1.3+, Periodic Notes replace what was previously only available for Daily Notes.
🚨 Working with Daily Notes requires either the core Daily Notes plugin or the Periodic Notes community plugin. Working with Weekly, Monthly, Quarterly or Yearly Notes requires the Periodic Notes community plugin.
This action searches for a text string or regular expression pattern in the current Daily/ Weekly/ Monthly/ Quarterly/ Yearly Note and replaces it.
This action returns an error if there is no Daily Note for the current date, so it's best to use it after the "Check For Existence Of Daily Note" action has determined that it actually exists.
Search term is a regular expression
By default, the search term is searched for as-is. With this option enabled, the search term is treated as a regular expression instead, and must follow the format
/search term/ (trailing flags are allowed).
Suppose you have a current Daily Note with the following content:
Today is a good day.
There's a number of options — and lot of fun to be had! 😉
Searching for a string and replacing with another string
With the search term
Today and the replacement
Tomorrow , the result will be:
Tomorrow is a good day.
Searching for a regular expression and replacing with a string
With a regex search term of
/[oa]/ig (meaning: all "o" or "a" characters, case-insensitive) and the replacement string
ui , the result is:
Tuiduiy is ui guiuid duiy.
Searching for a regular expression and replacing with capture groups
Using regex together with capture groups is a powerful combination. For example, if a search term is
/(my) (note)/ , and the note in questions contains "my note", then "my" and "note" will be available in the replacement as
$2 , respectively.
Here's a concrete example: With a regex search term of
/([oa])d([oa])/ig (meaning: an "o" or "a" character followed by a "d" followed by an "o" or "a" character, case-insensitive) and the replacement string
$2d$1 (meaning: the second capture followed by a "d" followed by the first capture), the result is:
Tadoy is a good day.
But if you run it again:
Today is a good day.
Changes / History
- Replaces the hard-coded Daily Note target with the ability to select Daily, Weekly, Monthly, Quarterly and Yearly Notes.