How can I condense stand-alone characters in Perl?
- by brydgesk
I'm trying to identify and condense single (uppercase) characters in a string.
For example:
"test A B test" - "test AB test"
"test A B C test" - "test ABC test"
"test A B test C D E test" - "test AB test CDE test"
I have it working for single occurrences (as in the first above example), but cannot figure out how to chain it for multiple occurrences.
$str =~ s/ ([A-Z]) ([A-Z]) / \1\2 /g;
I'll probably feel stupid when I see the solution, but I'm prepared for that. Thanks in advance.