'Who\'s going to the store?" "Us," she replied."'
Yeah, I know. "She" is using pitiful grammar, but it's all I could come up with on the spur of the moment.
Here, you lose capitalization with d4vis's regex. The unknown author came up with a nifty trick to preserve capitalization. However, it's not very clear. I'm also wondering if some versions of locale might break it depending upon the alphabet used.
Instead, I'd use something like the following (which I feel is more clear -- but untested):
Cheers,s/\b([Uu])s\b/$1 eq 'U' ? Them : them/eg;
Update: Oy! That's what I get for untested code. I guess tilly and I will send the rest of the day spanking each other (figuratively speaking).
Here's the correct version of the regex (which I still think is clearer than tilly's solution):
Tilly's solution, however, is better with multiple substitutions.$test =~ s/\b([Uu])s\b/$1 eq 'U' ? "Them" : "them"/eg;
In reply to (Ovid) Re: a simple substitution question
by Ovid
in thread a simple substitution question
by d4vis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |