Drafts Action Directory

Replace Example

Posted by agiletortoise, Last update 5 months ago

Example script showing how to create a saved regular expression replace action. Edit the regular expression and replaceWith variables at the top to modify for different saved replacement function.

Install

Steps

  • script

    // define regex to use...
    const findRegex = /([A-Za-z]*) ([A-Za-z]*)/g;
    // define replacement expression...
    const replaceWith = "$2 $1";
    
    // do the replacement...
    draft.content = draft.content.replace(findRegex, replaceWith);
    draft.update();

Options

  • After Success Default
    Notification Info
    Log Level Info

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.