Hello rnaeye,

To capture 10 or more consecutive G characters, you don’t need (G)\1{9,}, just use (G{10,}), which is simpler and easier to read.

Note than when you have a regex of the form / .* (G{10,}) /x, the first .* is greedy and will match as much of the G-sequence as it can, so the second capture will contain only the 10 Gs it needs to satisfy the match. If you want all the Gs (15 for the sample data given), you need to make the first match non-greedy: / .*? G{10,} /x.

Your requirements are not clear (to me). Please provide the exact output you desire for the given input data (and additional lines of input together with the desired output for each). In the meantime, I’m guessing you want to find a 10-character ACTG sequence immediately following the specific sequence ACTCCAGTCACGCCAATATCTCGTAT and followed (but not necessarily immediately) by a 10+ sequence of G characters:

use 5.18.2; while (my $line = <DATA>) { say; if ($line =~ m/ (ACTCCAGTCACGCCAATATCTCGTAT) ([ACTG]{10}) .*? (G{1 +0,}) /x) { say for $1, $2, $3; # Can use @{^CAPTURE} in Perl 5.25.7 an +d later } } __DATA__ GGCTTTCCGTTGTTGCTGGGTGTGGGGGGCGGGCGAGATTGGAAGAGCACACGTCTGAACTCCAGTCACG +CCAATATCTCGTATGCCGTCTTCTGCTTGAAAAAAGGGGTGGGGGGGAGGGGGGGCGGGGGGGGGGGGG +GGAGGGGGGGAG

Output:

13:18 >perl 1986_SoPW.pl ACTCCAGTCACGCCAATATCTCGTAT GCCGTCTTCT GGGGGGGGGGGGGGG 13:18 >

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


In reply to Re: help with regex by Athanasius
in thread help with regex by rnaeye

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.