[Python] regex that doesnt match values in double quotes

Discussão em 'Python' iniciado por Stack, Janeiro 21, 2025.

  1. Stack

    Stack Membro Participativo

    I have this test string

    '{"hello": "my-friend", "hello2": "my friend", "field": True, "nxt":"hello:what", "nxt2": Mystr}'


    And I want to match, in this case, only Mystrand True. So I want to match values that arent quoted.

    My first approach:

    ":(?: )?(.*?)?[\,\}]


    regex101.com picture

    Then I came across this question and I tried to adopt to my scenario. Unfortunately failing on that one.

    "[^"\\]*(?:\\.[^"\\]*)*"(*SKIP)(*F)|(?<!\S)([^"\s]+)(?!\S)


    regex101.com picture

    I would also like to understand whats going on. My approach is clear for me. The one I copy pasted not really so far.

    Later I will use the regex in a python script using re.

    Continue reading...

Compartilhe esta Página