in reply to another string replacement with uppercase :: converting C macros to C++
Beware the wily corner case. I don't know if '#ifdef ___xxx___' and the cases that follow it are pertinent to your application, but just something to think about:
c:\@Work\Perl\monks>perl -wMstrict -le "my @ln = ( '#ifdef __some__Long_name__', '__w_x__y_z__', '__aa_bb__cc___dd__ xxx __pp__qq__', '#ifdef ___xxx___', '#ifdef __xxx', '#ifdef xxx__', ); ;; for my $s (@ln) { print qq{'$s'}; $s =~ s{ \b __ (\w+?) __ \b }{\U$1}xmsg; print qq{'$s' \n}; } " '#ifdef __some__Long_name__' '#ifdef SOME__LONG_NAME' '__w_x__y_z__' 'W_X__Y_Z' '__aa_bb__cc___dd__ xxx __pp__qq__' 'AA_BB__CC___DD xxx PP__QQ' '#ifdef ___xxx___' '#ifdef _XXX_' '#ifdef __xxx' '#ifdef __xxx' '#ifdef xxx__' '#ifdef xxx__'
Give a man a fish: <%-{-{-{-<
|
|---|