Daily Notes / Search And Replace In Daily Note

Screenshot of the action

This action searches for a text string or regular expression pattern in the current Daily Note and replaces it.

Regular expressions must be valid JS expressions, please see MDN web docs (unaffiliated) or RegExr (unaffiliated) for detailed information.

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.


Available Options

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).


Examples

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.

Screenshot of the action


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.

Screenshot of the action


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 $1 and$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.

Screenshot of the action

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.