If I have a URL contstruct
/SomePart/#/Group1/Group2
I need to return the group1 and/or group2, i.e. the url could be either
/SomePart/#/Group1
OR
/SomePart/#/Group1/Group2
The current regex I have only gets the first part, not sure how to extend to the latter.
SomePart\/\#\/([a-zA-Z0-9_-]+)
Do you need to use a regex? Often using a regular expression is overkill. A few lines of code will be faster, and more maintainable than a big regular expression.
If your language has a split method just use that and check the last two items in the generated array.
This pseudo-code is probably a good starting place. In parting, an applicable quote:
Save your cleverness for something else 🙂