[Python] Python capture a specific pattern inside a string with regular expressions

Discussão em 'Python' iniciado por Stack, Julho 20, 2025.

  1. Stack

    Stack Membro Participativo

    I have a string like this '6\' 3" ( 190 cm )' and I would like to extract '190 cm' only using regular expressions. I can't find the appropriate pattern to look for.

    I have tried

    string = '6\' 3" ( 190 cm )'
    pattern = re.compile(r'[^\\( 0-9+ \\)]')
    pattern.findall(a)


    but it returns ["'", '"', 'c', 'm']

    Thanks for helping!

    Continue reading...

Compartilhe esta Página