Duh, it's actually much simpler, and this one even captures the single character(s)! (Update 2: See Variable-Width Lookbehind (hacked via recursion))
/(.)(?!((?<=(?!\1).(?=(?2)).|(?=\1)..))|.*\1)/s
In reply to Re^2: Regex: matching character which happens exactly once (updated)
by haukex
in thread Regex: matching character which happens exactly once
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |