Are you getting the original data one entry at a time, or are several entries munged together?

The solution is simple if you get the data one entry per line and there is no more than one word for the second label ('Author' in your example). A slight modification of McDarren's sample is what you are after:

use strict; use warnings; my $line = "some text Programming Languages: C++, Java Author: John D +ate Created: 20004-01-05 10:23"; my ($text) = $line =~ / ^[^:]* # Skip everything from the start of line until the first : :\s+ # Skip the : and any trailing white space ( # Capture (?: # Group, but don't capture (?! # look ahead an fail to match if given pattern fou +nd \s+\w+: # Pattern to fail on - space word : ). # Capture a character if the look ahead didn't fai +l )* # Do it as many times as possible ) # Close the capture /x; # x flag ignores most white space and allows comments print $text;

Prints:

C++, Java

DWIM is Perl's answer to Gödel

In reply to Re^3: RegEx question by GrandFather
in thread RegEx question by mariuspopovici

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.