[Python] Splitting string into two parts with digits occurring in both parts

Discussão em 'Python' iniciado por Stack, Fevereiro 8, 2025.

  1. Stack

    Stack Membro Participativo

    I have a sample string like 3425%4368, % in the string devide it into two parts, I want to find all digitals in the first part that has occurrence in the second part.

    you can see, 3 and 4 in the first part can also be found in second part.

    re.findall(r'(\d).*%.*\1', '3425%4368')


    is my code.

    it only returns 3. I can not figure out why the script does not match 4, thanks!

    Continue reading...

Compartilhe esta Página