in reply to Re: Removing Flanking "N"s in a DNA String
in thread Removing Flanking "N"s in a DNA String

As metioned already, no need for the character class.. Also, (although i tend to prefer the 2 separate statements as well), this can be written as one:
$dna =~ s/(^N+|N+$)//g;

Replies are listed 'Best First'.
Re^3: Removing Flanking "N"s in a DNA String
by blazar (Canon) on Nov 08, 2005 at 08:52 UTC
    Also,
    s/(?:^N+|N+$)//g;
    since we don't really need capturing. Which makes me think that ideally one may want it, instead, to see the text that has been substituted. But then he would only get the N's at ^ (if any) as $1 or . Which in turn make me wonder why there's this asymmetry between s/// and m//, since the latter, in list context and with /g does return all captures while the former just returns a true (or false) value in any context, precisely the numer of matches (or the empty string)...