A Find/Replace "Step" for Custom Actions (with RegEx)


Here you go: https://actions.getdrafts.com/a/1Fu


I think this might be the sort of thing you are after.

// define regex to use...
//Drop the double quotes from the original and add a space after page
const findRegex = /\[page /g;
// define replacement expression...
const replaceWith = "#@";

// do the replacement ...
draft.content = draft.content.replace(findRegex, replaceWith);

//Do some more replacements...
draft.content = draft.content.replace(/^highlight #@/gm, "#@");
draft.content = draft.content.replace(/(#@[0-9]+)]: /g, "$1\n");

//Update the draft

Hope that helps.


This is great - thank you both for your help with this!


Great - thanks for sharing!


Just as an addendum, please also write Readdle and ask them to offer better export options for annotations, including turning off or modifying the “highlight” text, and offering direct export to Drafts rather than having to copy and paste from an email draft… I’ve done this before but they don’t seem to think enough people care about it to bother changing anything.


Will do - It’s really astonishing that there isn’t a more flexible way of dealing with annotations.