That's tremendously ugly. I'm not even going to try to make the code work. In fact, all I'm doing here is making it somewhat readable so your code can be worked with. This code is still very fragile and you should be using a proper parser. I figure that whether you use this or not it's a good example of how to rewrite your regex for readability and what to do with the /x parameter.

The specific things I did were throw away all those \s{0,2} constructs in favor of \s+. The .{0,50} construct was completely breaking things so I replaced those with [^"]+ since that better expresses your intent. And of course I used /x so I could throw white space into the expression and format it for readability.

m{<gene_seq \s+ id \s+ = \s+ "(\d+)" \s+ status \s+ = \s+ "([^"]+)" \s+ CDS_number \s+ = \s+ "(\d+)" \s+ number_of_CDSs \s+ = \s+ "(\d+)" \s+ sequence_source \s+ = \s+ "([^"]+)" \s+ startpos \s+ = \s+ "(\d+)" \s+ endpos \s+ = \s+ "(\d+)" \s+ startopen \s+ = \s+ "(\d+)" \s+ endopen \s+ = \s+ "(\d+)" \s+ complement \s+ = \s+ "([^"]+)" \s+ >}x

Fun Fun Fun in the Fluffy Chair


In reply to Re: Regexp problems by diotalevi
in thread Regexp problems by matth

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.