in reply to Re: Case-preserving regexp search and replace?
in thread Case-preserving regexp search and replace?

I tried it, and it doesn't work as needed: I need it to match the case of the last letter. So if I want to replace "FOOBAR" with "whatever", it will return "WHATEVer" instead of "WHATEVER".

Newever versions of the Regexp FAQ have some routines not online here that do that fiddling with bits in ASCII. Not necessarily Unicode compliant but neat tricks nontheless.

  • Comment on Re: Re: Case-preserving regexp search and replace?

Replies are listed 'Best First'.
Re: Re: Re: Case-preserving regexp search and replace?
by japhy (Canon) on Aug 31, 2001 at 09:26 UTC
    If you want to keep the case of the last letter, then the other solution in perlfaq6 is what you want.

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;