y/a-z/A-Z/ (was Re: sed: how to capitalize replacement text?)
Randal L. Schwartz @ Stonehenge
merlyn at intelob.intel.com
Wed Apr 5 01:15:17 AEST 1989
In article <426b0af2.142c4 at retina.engin.umich.edu>, brian at caen (Brian Holtz) writes:
|
| Is there a way to uppercase the pattern text in the replacement text
| with sed's substitute command? In ex/vi, you just say
| s/regexp/\U&/
| but not, apparently, in sed/ed.
You can capitalize *all* of the sed pattern space with
y/a-z/A-Z/
which is not in the sed paper (if I remember right) but is tucked away
on the sed manpage. To capitalize just a regexp takes a bit of work
with sed. Use perl instead :-), as in:
s/(regexp)/($y = $1) =~ y|a-z|A-Z|, $y/eg;
(Thanks, Larry Wall...)
--
/=====Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095========\
{ on contract to BiiN (for now :-) Hillsboro, Oregon, USA. }
{<@intel-iwarp.arpa:merlyn at intelob.intel.com> ...!uunet!tektronix!biin!merlyn }
\=====Cute quote: "Welcome to Oregon... home of the California Raisins!"======/
More information about the Comp.unix.questions
mailing list