in reply to Regex: matching character which happens exactly once
Also, it seems you want a forward reference, in the same spirit as a backref -- something the regex engine will go check after "filling" the ref:
my ($match) = /^(?:[^\1]*)(.)(?:[^\1]*)$/;
Here rendered as \1, just like the backref.
As the first capturing paren hasn't been encountered before the backref mention triggers different behavior in the regex path. This will make backtracking more painful, and possibly more likely to be pathological, but one has to assume some risk...
-QM
--
Quantum Mechanics: The dreams stuff is made of
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Regex: matching character which happens exactly once
by AnomalousMonk (Archbishop) on Oct 24, 2017 at 03:05 UTC | |
by QM (Parson) on Oct 24, 2017 at 09:16 UTC | |
by AnomalousMonk (Archbishop) on Oct 24, 2017 at 16:51 UTC | |
Re^2: Regex: matching character which happens exactly once (using global memory)
by LanX (Saint) on Oct 23, 2017 at 14:33 UTC | |
by QM (Parson) on Oct 23, 2017 at 14:46 UTC | |
by LanX (Saint) on Oct 23, 2017 at 14:50 UTC | |
by QM (Parson) on Oct 23, 2017 at 16:57 UTC | |
by LanX (Saint) on Oct 23, 2017 at 18:51 UTC |
In Section
Seekers of Perl Wisdom