[Python-Dev] \G (match last position) regex operator non-existant in python?

MRAB python at mrabarnett.plus.com
Sat Oct 28 20:41:48 EDT 2017


On 2017-10-29 00:48, Steven D'Aprano wrote:
> On Sun, Oct 29, 2017 at 12:31:01AM +0100, MRAB wrote:
> 
>> Not that I'm planning on making any further additions, just bug fixes 
>> and updates to follow the Unicode updates. I think I've crammed enough 
>> into it already. There's only so much you can do with the regex syntax 
>> with its handful of metacharacters and possible escape sequences...
> 
> What do you think of the Perl 6 regex syntax?
> 
> https://en.wikipedia.org/wiki/Perl_6_rules#Changes_from_Perl_5
> 
I think I prefer something that's more like PEG, with quoted literals, 
perhaps because it looks more like a programming language, but also 
because it's clearer than saying "these characters are literal, but 
those aren't". That webpage says "Literals: word characters (letters, 
numbers and underscore) matched literally", but is that all letters? And 
what about diacritics, and combining characters?

I'm not keen on <before ...> and <!before ...>, I like & and ! better, 
but then how would you write a lookbehind?

Named rules are good, better than regex's use of named capture groups, 
and if you quote literal, then you wouldn't need to wrap rule call in 
<...>, as Perl 6 does.


More information about the Python-Dev mailing list