Many thanks to @satikusala , @mwra , @eastgate and @webline who all helped solve my little problem, namely how to “clean” text pasted from DEVONthink into a Tinderbox note’s $Text.
Since many people in the Tinderbox forum use DEVONthink and may also use its annotation feature (the results of which, as you will know, can be be copied and pasted as text e.g. into Tinderbox), I post a few screenshots here. Also, since the format in which you get text from DEVONthink annotations differs from the format @satikusala used, I show the action code which transforms it into my favourite format. Obviously, if you have different needs, you can easily alter the RegEx.
But the important thing for me is: One can indeed search and replace many occurrences in one note; and it can be done without loops or stream operators (which, however, can also fulfill this task).
Here is my starting text - straight out of DEVONthink, pasted into the $Text field:
Here is the action code that I use in the stamp (sorry there’s so much German in it…):
$MyString=$Text.replace(“([0-9]+).+\t”,“(p. $1) “);
$MyString=$MyString.replace(”\n\n”,“\n”);
$Text=$MyString;
The first line does the conversion (I want to drop everything except the page number and the text).
The second line serves cosmetic purposes by reducing the number of line breaks between entries to one.
And the third line puts the stuff from the intermediary variable back into $Text.
The result looks like this:
Many thanks again to the forum - I hope this will help someone else.
Edit: In the above action code, I have put in “+” instead of “{1,3}” which is shorter and correct.