in reply to Regex - remove characters (pattern not terminated)
Just guessing, but maybe something like this?
my $temp_seq = "fooXXXXXXbar"; my $tag_seq = "foo"; $temp_seq =~ s/^($tag_seq)\w{6}(.*)/$1$2/; print $temp_seq; # "foobar"
(removes the six characters following the search pattern "foo", which must occur at the beginning of $temp_seq)
See s/// under Regexp-Quote-Like-Operators.
Another way to achieve the same would be
if ($temp_seq =~ /^$tag_seq/) { substr($temp_seq, $+[0], 6) = ''; }
where $+[0] is the position after the matched pattern.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex - remove characters (pattern not terminated)
by AnomalousMonk (Archbishop) on Jun 28, 2010 at 20:32 UTC | |
|
Re^2: Regex - remove characters (pattern not terminated)
by twaddlac (Novice) on Jun 29, 2010 at 18:47 UTC | |
by almut (Canon) on Jun 29, 2010 at 19:05 UTC | |
by twaddlac (Novice) on Jun 29, 2010 at 19:18 UTC |