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.
-BirdIn reply to Re: split with regex
by Bird
in thread split with regex
by Emanuel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |