Refactor code for providing a list of strings to be used in a regexp or expression