I have plain text which is kind of pre-formatted with hyphenated words (and similar).
So I thought it could be an idea to use regex to join the hyphenated words.
But the text is in German (will be same in other languages with special characters as well) and characters like ä, ö, ü won’t work.
Here what I have and which doesn’t work
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
property cA : a reference to current application
property theContent : "Eine Übertragung durch kontaminierte Oberflä- chen ist theoretisch vorstellbar, da SARS-CoV-2- Viren unter Laborbedingungen auf Flächen eine gewisse Zeit lang infektiös bleiben können. Im Vergleich zur aerogenen SARS-CoV-2-Übertragung wird die Bedeutung der Verbreitung des Virus durch kontaminierte Flächen aktuell gering einge- schätzt. Die Inkubationszeit beträgt 2 – 14 Tage (im Durchschnitt 5 – 6 Tage). Als Haupteintritts- pforten für SARS-CoV-2 gelten die Schleimhäute des Nasen-Rachen-Raums; eine Aufnahme via Kon- junktiven und Tränennasengang wird diskutiert, konnte allerdings bislang nicht eindeutig belegt werden."
set theString to cA's NSString's stringWithString:theContent
set checkString to theString's mutableCopy()
-----------------------------------------------------------------
set regEx to "\\w-\\s\\w"
set cRegex to cA's NSRegularExpression's regularExpressionWithPattern:(regEx) options:(0) |error|:(missing value)
set zRangeList to (cRegex's matchesInString:(theString) options:(0) range:({0, theString's |length|()}))'s valueForKey:("range")
set vCount to (count of zRangeList)
repeat with i from vCount to 1 by -1 --zRange in zRangeList
# replace the "- " in the range
end repeat
Any hints how to proceed are appreciated.
Happy Holidays