in reply to need a complex regex

You don't say whether you are processing this line by line, or need to extract your bits from a multiline lump of data. You are also not at all clear as to which parts of the lines you wish to keep, and whether you want to capture them as 2 or 3 pieces.

This assumes that you processing line by line and want 3 pieces from each line.

if( $line =~ /^([^:]+): (.+) \((\d+) minutes ago\)$/ ) { my( $name, $text, $delay ) = ( $1, $2, $3 ); }

The regex is saying

  1. Capture 1 or more non-':' characters between the start of the regex and the first colon into $1.
  2. Then insist on, but skip, a ': '
  3. The capture one or more characters after that space and upto the next sequence into $2.
  4. Match but skip a space preceding a literal '('

    followed by one or more digits (captured to $3),

    followed b y the literal text ' minutes ago)',

    followed by the end of line.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller