Perl: the Markov chain saw | |
PerlMonks |
Re^2: [OT] Thoughts on Ruby's new absent operator?by LanX (Saint) |
on Mar 24, 2017 at 16:59 UTC ( [id://1185808]=note: print w/replies, xml ) | Need Help?? |
> Anyway, I get the idea that (?~abc) would be analogous to ^x, except that the former is for multi-character sequences. Thanks, now I get the idea and I have to admit that I missed this feature in the past, though I can't recall when exactly. But all useful use-cases which come to my mind involve strict boundaries, like parsing a grammar and explicitely excluding certain commands. Like parsing a html but not wanting "a" and "img"-tags while allowing "anchor" This would mean to use something like /<\s*\b(?~a|img)\b(.*)>/ and this should be achievable with
please note how important it is to repeat the delimiting \b in case 1, which might justify the use of (?~...) . Though to be sure I'd need to test the Ruby implementation, and I'm not willing to install yet.
Cheers Rolf
PS: Choosing HTML as data grammar was - as always - unfortunate. You are free to propose something different.
In Section
Meditations
|
|