[PLUG] substitution question...

Keith Lofstrom keithl at kl-ic.com
Tue Dec 9 18:33:25 UTC 2008


On Mon, Dec 08, 2008 at 02:14:07PM -0800, Don Buchholz wrote:
> Eitan Tsur wrote:
> >Anyone know how to convert the capitalized character after apostrophe(s) in
> >a string to lowercase? (using s/// in sed, perl, etc...)
> >_______________________________________________
> 
> Use tr(1), e.g.
> 
>     $ tr A-Z a-z  <in > out
> 
> Also, in Perl
> 
>     tr/SEARCHLIST/REPLACEMENTLIST/
>     y/SEARCHLIST/REPLACEMENTLIST/
> 
>    ... see the perlop(1) man page for details ..

You misread the question - Eitan wants to replace FRED'S with
FRED's, which is more grammatically correct (me, I would prefer
Fred's ).   A lot would depend on context, which Eitan did not
give.  Is this an isolated word, or correcting words as part of
text, or what?  For example, Fixing "FRED'S NAP'STER FILE" 
will be interesting if the second S is not supposted to get
lower cased;  otherwise, just replace all instances of "'S"
with "'s".    If text, what about end-of-line issues?  What
about non-Roman characters?  What matters here?
 
Sometimes, the best way to get started on a problem like this
is to produce a few examples and expected outputs, and "design
to the test".  A clear set of tests may result in simpler code.

Keith

-- 
Keith Lofstrom          keithl at keithl.com         Voice (503)-520-1993
KLIC --- Keith Lofstrom Integrated Circuits --- "Your Ideas in Silicon"
Design Contracting in Bipolar and CMOS - Analog, Digital, and Scan ICs



More information about the PLUG mailing list