Forum Moderators: phranque
The PCRE pattern (\w+) matches all the way to the end of the input and then backs off and retries many times until a match is found. I try to avoid this.
The other pattern using "local OR" logic, is OK when there is only a small number of options, but becomes unwieldy (and slow{er}) when the list is long.
If there were a separator between the words, your pattern could be ([^\-]+) which means "read until the next hyphen". Readable in a single left-to-right pass this is the fastest of all.