Fix #3852

Added test case from the aforementioned issue.
No longer reversing regex as it was problematic for constraints.
Fixing expectation for two optional subdomains with one missing.
Adding test cases for nested subdomains.
Removing comments RE: reverse regex
Merge branch 'hotfix/3855'

Close #3855
Fixes #3852