[SOLVED] Request for script assistance = delete text


I have text in the form of:

The Economist noreply@e.economist.com

I’d like to delete all the text that is not the actual email address. I’ve got a regex which should select the “The Economist <”


but I’m not sure how to issue a delete command. Can anyone point me in the right direction? (I’m assuming deleting the last “>” will then by trivial, but maybe I’m just naive!)

Rather that thinking of a deletion, think of it as a replacement. Regular expressions could be used for a substitution(/replace) in a string for example.

There are several ways to do that other than regular expressions; but, regular expressions are a great choice.

Take your text string and set it equal to the text string with the substitution applied. That applies the ‘deletion’ to the string.

To apply that to a draft, you would either be working with the draft object and updating the content then calling an update(). To apply it to the editor, you would probably be using one of the set functions.

Hope that helps.

Thanks. That makes perfect sense!