We know that the vertical bar is special, because our line splitting
pattern had to escape it with a backslash. That's because an unescaped
vertical bar ``|'' matches either the regular expression that
precedes it or the regular expression that follows it.
a = "red ball blue sky"
|
showRE(a, /d|e/)
|
� |
r<<e>>d ball blue sky
|
showRE(a, /al|lu/)
|
� |
red b<<al>>l blue sky
|
showRE(a, /red ball|angry sky/)
|
� |
<<red ball>> blue sky
|
There's a trap for the unwary here, as ``|'' has a very low precedence.
The last example above matches ``red ball'' or ``angry sky'', not ``red
ball sky'' or ``red angry sky''. To match ``red ball sky'' or ``red
angry sky'', you'd need to override
the default precedence using grouping.