I want to separate a string into two parts if a token from an array is found at the end of the string. I have tried this:
x = "Canton Female"
GENDER_TOKENS = ["m", "male", "men", "f", "w", "female", "wom"]
x.partition(/(^|[[:space:]]+)[#{Regexp.union(GENDER_TOKENS)}]$/i)
#=> ["Canton Female", "", ""]
But although the word "female" is part of my tokens, it is not getting split out. How do I adjust my regex so that it gets split properly?