[Python] Using set operators with python regex module

Discussão em 'Python' iniciado por Stack, Abril 13, 2025.

  1. Stack

    Stack Membro Participativo

    I'm having trouble getting set operators to work in the regex module (regex 2013-11-29) in python-3.x. For example, to match ASCII characters minus punctuation I have tried:

    import regex as rx

    data = '(foo)'
    for m in rx.finditer(r'[\p{ASCII}--\p{P}]+',data):
    print(m.group(0)) # expect 'foo', getting '(foo)'


    The documentation gives this example:

    [\p{N}--[0-9]] # Set containing all numbers except '0' .. '9'

    Am I missing something here?

    Continue reading...

Compartilhe esta Página