String manipulation to get rid of enclosed dash

What would be the smartest way to get rid of enclosed dashes in strings containing words, while changing the letter that followed the dash to lowercase?

Old string: Abluft-Volumen-Strom
Desired string: Abluftvolumenstrom

Hey Hans,

I don’t believe Keyboard Maestro’s regular expression syntax supports in-line (upper/lower)-case changes.

You have the Satimage.osax installed – yes?

If so then it’s not too hard:

set theText to "Abluft-Volumen-Strom"
set newText to change "-([[:upper:]])" into "\\l\\x" in theText with regexp without case sensitive

NOTE: Change the “x” in the above script to a 1 (one). What you see as \\l is a lower case L. (This bit is made necessary by a bug in the Discourse software that has remained unfixed for a bleeping long time.)


Thank you and Merry Christmas to you and all other participants in this marvellous forum!


This is the final result:

Keep in mind that the hyphen in German compounds can have semantic implications.

Stupid example:

Garagen-Möbelverkauf: presumably correct
Garagenmöbel-Verkauf: different meaning, presumably wrong here
Garagen-Möbel-Verkauf: ambiguous
Garagenmöbelverkauf: ambiguous

So, if you are going to batch-flatten all hyphen compounds into single-word compounds without closer examination, you may lose information. (Some formerly unambiguous words may turn into ambiguous words.)

(Besides that, some longish compounds will become hard to read if you eliminate the hyphens.)

Thanks for the nice examples, Tom! I’ll use the macro interactively, only when adding new terms, via a dialogue box. But your warning is appreciated.