There are some issues in your pattern
You don't need a capturing group around the whole pattern.
?:is creating a non capturing group, it is not limited to optional groups.
multiline, but this is a bit misleading it affects only the anchors
$to match also the start and end of a row and not only of the string.
What you want is the modifier
singlelinemodifier. It treats the whole string as one line, and affects the
.to match also newline characters.
Umakes your whole regex ungreedy. This is not what you want, because it affects also your optional group and because it is at the end of the pattern it will never match.
You need to match the
:in your string
So I would remove
Uand make only the first quantifier ungreedy, by adding a
So I think your regex should be:
This would put the first part between the
@ in the first capturing group and the parameter in the second group.
See it here on Regexr