# Matched element is passed to $pat for further processing. $pat = $1; $pat =~ s/_x_x$//i; #This is not working. $pat =~ s/_x_s$//i; #This is working. $pat =~ s/_x$//i; #This is not working. print $pat;