in reply to Re: Regex: Case insensitive search but case sensitive replace
in thread Regex: Case insensitive search but case sensitive replace

Thx L~r !

But the generic version would replace both 'jane' & 'Jane' with 'Jane'.

I'm looking for a way to search insensitive but the replace should keep the case of the word/text ...

Thx again !

  • Comment on Re: Re: Regex: Case insensitive search but case sensitive replace

Replies are listed 'Best First'.
Re: Re: Re: Regex: Case insensitive search but case sensitive replace
by Limbic~Region (Chancellor) on Nov 17, 2003 at 10:40 UTC
    Anonymous Monk,
    I provided 3 examples because you were not exactly clear what your definition of "case insensitive" and "case sensitive" was in your post. The second example is closest to what you mean, but you might have also meant:
    $string =~ s/(jane)/##$1##/i;
    This would allow any letters to be any case, but be preserved in the replacement.

    Cheers - L~R

      Perfect ! That was the regex i was looking for :-)

      Guess i should use my brain next time and first read 'perlre' ;-)

      Thank you all very much !!