/^($foo)_¦_($foo)_¦_($foo)$/
I want to match $foo if I find it bounded by underscores, or at the beginning of the string followed by an underscore, or at the end of the string preceded by an underscore.
I'm wondering if there's a way to do this without the alternation (¦) characters.