[Python] Regular expression for Python to detect a string and find code block corresponding to...

Discussão em 'Python' iniciado por Stack, Setembro 27, 2024.

  1. Stack

    Stack Membro Participativo

    I have below text

    text = '''
    here are some examples
    @with some text
    @then some more text
    @ some more@text @moretext probedetail
    how are you
    something is going on
    }
    how has it been
    weather is good
    '''


    I want to extract the string from above text starting from @ till }, the condition is @ should be closest to the string 'probedetail' but not in same line it should be in above lines and end at }

    so from above text I am expecting

    @then some more text
    @ some more@text @moretext probedetail
    how are you
    something is going on
    }

    Continue reading...

Compartilhe esta Página