Hena has asked for the wisdom of the Perl Monks concerning the following question:
And the result of it is#!/usr/bin/perl use warnings; use strict; while (<DATA>) { chomp; print "$_ -> "; m/(\w)\Z/; my $last = $1; if (s/($last{3,})\Z/$last$last/) { my $len = length($1)-2; print "$len -> $_\n"; } else { print "\n" } } __DATA__ ACTGCTAGGGGGGG TCAGCTAGCNA ACTGSCGACAAAA GTCTGAGTTATTT
The prints are there for sake of understanding the situation. However I do need the length of the trimmed string. Though I can of course just use length() after trimming to get it.ACTGCTAGGGGGGG -> 5 -> ACTGCTAGG TCAGCTAGCNA -> ACTGSCGACAAAA -> 2 -> ACTGSCGACAA GTCTGAGTTATTT -> 1 -> GTCTGAGTTATT
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex related question
by Perlbotics (Archbishop) on Aug 08, 2011 at 07:09 UTC | |
by happy.barney (Friar) on Aug 08, 2011 at 08:55 UTC | |
by Hena (Friar) on Aug 08, 2011 at 07:24 UTC | |
|
Re: Regex related question
by davido (Cardinal) on Aug 08, 2011 at 07:09 UTC | |
by Marshall (Canon) on Aug 08, 2011 at 08:22 UTC | |
by davido (Cardinal) on Aug 08, 2011 at 08:28 UTC | |
by Hena (Friar) on Aug 08, 2011 at 07:26 UTC | |
by davido (Cardinal) on Aug 08, 2011 at 07:32 UTC | |
|
Re: Regex related question
by davido (Cardinal) on Aug 09, 2011 at 08:53 UTC | |
|
Re: Regex related question
by JavaFan (Canon) on Aug 08, 2011 at 08:36 UTC |