I think you'll slap your forehead for this one. (:
Does any monk have an idea why [...] the initial pipe needs to be escaped as well
For the same reason that you realized that you needed to do some escaping in the first place. /|/ matches "either the empty string or the empty string" while /\|/ and /[|]/ match a single vertical bar character.
So s#|#\\|#g replaces every empty substring of a string with '\|'.
- tyeIn reply to Re^4: Creating regex from arrays (oops)
by tye
in thread Creating regex from arrays
by debiandude
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |