If you're trying to keep all the data you're matching, I don't know if split is the best solution. You should be fine just using a global match with capturing. Something like...

my $data = "00:01:00Something here bla bla blaTYPE00:02:00". "Something here bla bla blaANOTHERTYPE00:03:00S". "omething here bla bla blaEVENMORETYPES"; my $moredata = "00:01:00Something here bla bla blaType00:0". "2:00Something here bla bla blaTypetoooo00:". "03:00Something here bla bla blaTYPETHREE"; my @lines = $data =~ /(\d{2}:\d{2}:\d{2}[^\d]*)/g; my @morelines = $moredata =~ /(\d{2}:\d{2}:\d{2}[^\d]*)/g; print "$_\n" for @lines; print "\n"; print "$_\n" for @morelines;

This assumes that the text between the digits won't contain any other digits. You may need to modify the [^\d]* portion of the regex if any digits may appear in the text section. From your examples, though, this appears to do what you need.

-Bird

In reply to Re: split with regex by Bird
in thread split with regex by Emanuel

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.