Action

Replace Example

Posted by agiletortoise, Last update over 6 years 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.

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
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.