There is also a tool to help understand Perl regular expressions:
YAPE::Regex::Explain. It will at least explain what is inside the regex delimeters.
use warnings;
use strict;
use YAPE::Regex::Explain;
my $re = '^([^{};]+[{};])(\s*\S+.*)$';
print YAPE::Regex::Explain->new($re)->explain();
The regular expression:
(?-imsx:^([^{};]+[{};])(\s*\S+.*)$)
matches as follows:
NODE EXPLANATION
----------------------------------------------------------------------
(?-imsx: group, but do not capture (case-sensitive)
(with ^ and $ matching normally) (with . not
matching \n) (matching whitespace and #
normally):
----------------------------------------------------------------------
^ the beginning of the string
----------------------------------------------------------------------
( group and capture to \1:
----------------------------------------------------------------------
[^{};]+ any character except: '{', '}', ';' (1
or more times (matching the most amount
possible))
----------------------------------------------------------------------
[{};] any character of: '{', '}', ';'
----------------------------------------------------------------------
) end of \1
----------------------------------------------------------------------
( group and capture to \2:
----------------------------------------------------------------------
\s* whitespace (\n, \r, \t, \f, and " ") (0
or more times (matching the most amount
possible))
----------------------------------------------------------------------
\S+ non-whitespace (all but \n, \r, \t, \f,
and " ") (1 or more times (matching the
most amount possible))
----------------------------------------------------------------------
.* any character except \n (0 or more times
(matching the most amount possible))
----------------------------------------------------------------------
) end of \2
----------------------------------------------------------------------
$ before an optional \n, and the end of the
string
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------