Reputation: 97
Can anyone explain what is being done below?
$name=~m,common/([^/]+)/run.*/([^/]+)/([^/]+)$,;
Upvotes: 0
Views: 167
Reputation: 386676
common
, run
and /
are match themselves.()
captures.[^/]+
matches 1 or more characters that aren't /
..*
matches 0 or more characters that aren't Line Feeds.[1]$
is equivalent to (\n?\z
).[2]\n
optionally matches a Line Feed.\z
matches the end of the string.I think it's trying to match a path of one or both of the following forms:
.../common/XXX/runYYY/XXX/XXX
common/XXX/runYYY/XXX/XXX
Where
XXX
is a sequence of at least one character that doesn't contain /
.YYY
is a sequence of any number of characters (incl zero) that doesn't contain /
.It matches more than that, however.
uncommon/XXX/runYYY/XXX/XXX
common/XXX/runYYY/XXX/XXX/XXX/XXX/XXX/XXX
The parts in bold are captured (available to the caller).
s
flag isn't used.m
flag isn't used.Upvotes: 4