Script: GetLinepart - jobisoft/quicktext GitHub Wiki

When replying to another mail, get lineparts of that other mail, for example fields of a form.

Script

let prefix = this.mVariables[0];
let suffix = this.mVariables[1];

var editor = this.mWindow.gMsgCompose.editor;
var text = editor.outputToString('text/plain', 0);

var result = text.match(prefix + "(.*)" + suffix);

if(result != null) return result[1];
return '';

Usage

Consider the following two mails you are replying to:

Form about customer satisfaction

Name: John Doe
City: Berlin
Satisfaction level: 5 Stars
2022-07-02 Form by SunnyTech
Form about customer satisfaction

Name: Jane Doe
City: London
Satisfaction level: 1 Star
2022-06-31 Form by SunnyTech

Search for a line with the prefix Name: and no suffix (will find John Doe and Jane Doe):

[SCRIPT=GetLinepart](/jobisoft/quicktext/wiki/Name:-)

Search for a line with the prefix City: and no suffix (will find Berlin and London):

[SCRIPT=GetLinepart](/jobisoft/quicktext/wiki/City:-)

Search for a line with the prefix Satisfaction level: and the suffix Star (will find 5 and 1):

[SCRIPT=GetLinepart](/jobisoft/quicktext/wiki/Satisfaction-level:-|-Star)

Search for a line with no prefix and the suffix Form by SunnyTech (will find 2022-07-02 and 2022-06-31):

[SCRIPT=GetLinepart](/jobisoft/quicktext/wiki/|-Form-by-SunnyTech)