Regex to match nested json objects

前端 未结 4 1656
失恋的感觉
失恋的感觉 2021-01-02 14:05

I\'m implementing some kind of parser and I need to locate and deserialize json object embedded into other semi-structured data. I used regexp:



        
4条回答
  •  有刺的猬
    2021-01-02 14:25

    Thanks to @Sanjay T. Sharma that pointed me to "brace matching" because I eventually got some understanding of greedy expressions and also thanks to others for saying initially what I shouldn't do. Fortunately it turned out it's OK to use greedy variant of expression

    \\{\s*title.*\\}
    

    because there is no non-JSON data between closing brackets.

提交回复
热议问题