in reply to Regex check

You might use //x to make your regex a bit more readable. Like this:

'/ [\w().-]* \(? ([\w.-])? \)? \s* -> \s* $ /x'

You could even use more than one line and comments to make the regex much clearer, but since we need to store it in a string I left that out

I don't see anything which would produce an error but the regex part between the two parens (and the parens themselves) will never match anything because the first part already matched it.