Remove Duplicate Return Char Macro (v9.2) - not working Regex
I found this Regex solution in regex101: build, test, and debug regex , but it does not work in Keyboard Maestro...
The replace with
value also looks odd there:
What is the leading forward slash for ?
Why are you including both a \r
and a \n
in the replacements ?
(That might yield a single line space on Windows, but not on macOS, where the default line break is the Unix convention of a single \n
)
Because if you look at his action you will see he has CR's and LF's in his data:
0000000 E s t e r n o r r a f i a . cr nl
7345 6574 6e72 726f 6172 6966 2e61 0a0d
0000020 cr nl A u m e n t o sp d a s sp d i
0a0d 7541 656d 746e 206f 6164 2073 6964
0000040 m e n s ? ? e s sp d o sp c o r a
656d 736e b5c3 7365 6420 206f 6f63 6172
0000060 ? ? ? ? o . cr nl cr nl S e i o sp c
a7c3 a3c3 2e6f 0a0d 0a0d 6553 6f69 6320
0000100 o s t o f r ? ? n i c o sp e s q
736f 6f74 7266 aac3 696e 6f63 6520 7173
0000120 u e r d o sp l i v r e . cr nl cr nl
6575 6472 206f 696c 7276 2e65 0a0d 0a0d
0000140 P u l m ? ? o sp e s q u e r d o
7550 6d6c a3c3 206f 7365 7571 7265 6f64
0000160 sp n o r m o t r a n s p a r e n
6e20 726f 6f6d 7274 6e61 7073 7261 6e65
0000200 t e .
6574 002e
0000203
I explained this to him on another thread. This appears to be a duplicate post.
And including both will inevitably produce double lines in the output for macOS. (linefeed followed by carriage return)
Single space normalized text for macOS can't have both.
Absolutely agree with you though that over-posting weakens the signal-to-noise ratio on the forum, and may even increase @peternlewis's hosting costs.
Good to:
- minimize the bulk, self-reference, and reading time
- maximize the problem-solving focus.
This is not necessarily true.
Text on the Mac is extremely confused as to line endings.
Traditional Mac OS was carriage return line endings (\r).
Modern Mac OS is generally line feed line endings (\n), however text on the clipboard remained with carriage return line endings much longer.
It is rare that DOS style carriage return&linefeed (\r\n) is used. But not unheard of, and should not result in doubled lines.
Linefeed followed by carriage return (\n\r) is never valid.
Any well behaved software should deal with text with any self-consistent line endings in any of the three styles (\n, \r, or \r\n).
For output, on modern Mac OS, I would recommend just line feed.
@Pedro.Carmo If I'm not mistaken /g (global) is also not supported by KM. Search the forum for the For Each
action.
Hey @Pedro.Carmo,
Your forward-slash syntax is not supported by Keyboard Maestro:
/[\r\n]+/gm
That's for scripting languages like Perl and JavaScript.
Nor are the 'g' and 'm' switches supported in the text.
However multiline can be turned on in the regular expression itself:
(?m)[\r\n]+
Global is on by default in KM's find/replace action, but that can be modified using the action's gear menu options (or contextual menu).
-Chris