[conspire] RElief: Re: CAPS - eyes hurt
Michael Paoli
Michael.Paoli at cal.berkeley.edu
Tue Dec 18 23:06:06 PST 2018
> Date: Tue, 18 Dec 2018 15:59:20 -0800
> From: Rick Moen <rick at linuxmafia.com>
> To: conspire at linuxmafia.com
> Subject: Re: [conspire] successful install, at last
>
> Quoting Paul Zander (paulz at ieee.org):
>
>> REPLIES BELOW, ALL IN CAPS
>
> Wow, my eyes hurt.
Ouch ...
Fortunately we have effective treatments for that, e.g. RElief can
be provided by REs - Regular Expressions ...
Which, e.g., can all be done in lovely vi(1), such as by doing:
:g/^[^a-z]*$/s/^.*[A-Z].*$/< \L&/
For those that don't quite grok vi/ex/REs:
: start ex command
g globally (for all matching lines)
/ begin Regular Expression (RE)
^ start of line
[ start of character class
^ negate
a literal a
- through
z literal z
] end of character class
* zero or more of the preceding "atom" (our character class)
$ end of line
/ end of RE (full line containing zero lowercase chars)
s substitute (for those lines that matched)
/ start of RE
^ start of line
. any single character
* zero or more of the preceding "atom" (any single char)
[ start of character class
A literal A
- through
Z literal Z
] end of character class
. any single character
* zero or more of the preceding "atom" (any
single char)
$ end of line
/ end of RE (full line containing an uppercase char)
< we substitute for our matched RE < and space
\L and everything following we lowercase it
& our entire matched RE
/ end of substitution
So that command, in vi(1), takes all lines that contain no lowercase letters
and at least one uppercase letter, and prepends < and space to the line
and changes all the uppercase letters to lowercase on that line.
More information about the conspire
mailing list