$R =~ s/\[[^\]]*?#[^\]]*?#.*?\]//gm;