from the examples given, my guess is that the need is for any sub-string matching "__A_" or "__A_A_" (where A is any alpha character) to be replaced by "__" (a double-underscore). (i assume the "g" in "__gPopalzi" is a typo.) in that case, this may be appropriate (UNTESTED):
$string =~ s/ __ (?: [a-zA-Z]_ ){1,2} /__/xms;
i also assume there is only one instance of the sub-string in a string, and so the /g regex modifier is not needed. also, that variations on the sub-strings "__AA_" and "__AA_AA_" will not occur.
note: more examples would help the humble monks to better understand the requirements. |