Like this: s/(?<=[^n])n|n(?=[^n])/^/ig
In reply to Re: replace fist and last occurrences of N by jwkrahn in thread replace fist and last occurrences of N by ini2005