How to find multiline text between curly braces?

python, regex

Solution

Use the option `re.MULTILINE` as a second argument to your re.compile/etc. call.

I would propose this regex: `_NAME_KEY_[^{]*+\{([^}]+)\}`

Explanation:

`_NAME_KEY_`: match "_NAME_KEY_"

`[^{]*`: match as many non-{-characters as possible (greedy)

`\{`: match a { character

`([^}]+)`: match (and capture) non-}-characters (greedy)

`\}`: match one } character

Problem

I have next input string: ``` ANIM "_NAME_KEY_" // Index = 26, AFrames = 1 { 0x301C AF 0x201C 1 0 0 FREE_ROTATE 0 FREE_SCALE_XY 100 100 } ``` How can i get whole string between two curly braces, just having _NAME_KEY_ ?

Original source