I was reading an article put together by Martin Fowler regarding Composed Regular Expressions. This is where you might take code such as this:
const string patt
It is fairly easy to read if you can have extended syntax.
/^
score \s+ (\d+) \s+
for \s+ (\d+) \s+
nights? \s+ at \s+ (.*)
/x
I personally prefer Perl 6 style regex. I think they're easier to read.
rule pattern{
score $= [ <.digits>+ ]
for $=[ <.digits>+ ]
night[s]? at $= [ .+ ]
}
After you perform a match against that rule $/
is associated with the matched text.
So something like this:
say "Hotel $/";
say $/.perl;
Would output something like this
Hotel name of hotel
{
'hotel' => 'name of hotel',
'nights' => 5,
'score' => 8
}