{[[group1 #xxx#]] text [[group2]] text2 [[group3 #something# else]]} #### ->" text group2 text2" #### $R =~ s/(.*?)(\[.*?\#.*?\#.*?\].*?)?(.*?)/$1$3/gm;
## ->" text group2 text2" ##
## $R =~ s/(.*?)(\[.*?\#.*?\#.*?\].*?)?(.*?)/$1$3/gm;