... the (*SKIP)(*FAIL) trick ... looked interesting, but does not seem applicable here.
I, too, have been trying to press this trick into service for this application and all my efforts have ended in tears.
... how does one determine that [some character] has been seen before?
The (*SKIP)(*FAIL) trick works with interpolations, variable alternations and variably-quantified atoms that are known at compile time. But as you noted, you can't know what characters you will encounter in an arbitrary string until run time, and then it's too late. Maybe that's why such impure practices as (?{ ...code... }) were invented in the first place.
... doubting whether it is possible at all with pure regexes ...
I'm slowly and reluctantly being driven to this conclusion myself — but I haven't yet given up all hope!
(BTW: I don't consider a solution fully acceptable unless it can be adapted to extract all singleton characters from a string in one pass. All the "pure" solutions I've seen so far only seem to work for a single singleton per string. Oh, well...)
Give a man a fish: <%-{-{-{-<
In reply to Re^4: Regex: matching character which happens exactly once
by AnomalousMonk
in thread Regex: matching character which happens exactly once
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |