my $re = qr/ \b event \s* = \s* " # Match word boundary, "event", # optional space, "=", optional # space, and a double-quote. ( [^"(]+ ) # Capture any quantity of anything # that is not a double-quote or an # open paren. ["(] # Anchor to another double-quote or # an opening paren. /x; # Extended pattern (literal whitespace # and comments aren't significant). if( $match =~ $re ) { print "Captured: [[$1]]]]"; }