I would suggest not using \n in a regular expression. Different systems use different characters for line endings. Also, the first line does not start with \n. Instead, try ^ for the start of a line and $ for the end.
Also, you have mismatched brackets.
Maybe something like this:
'/([\w-.]+)/([\w-.]+)$/m'
\w matches alpha-numeric and underscore.