i am trying to find a certain pattern between a start and end patterns for multiple lines. Here is what i mean:

i read a file and saved it in variable File, this is what the original file looks like:

File:

```
...
...
...
Keyword some_header_file {
   XYZ g1234567S7894561_some_other_trash_underscored_text;
   XYZ g1122334S9315919_different_other_trash_underscored_text;
}
...
...
...

```

I am trying to grab the **1234567** between the g and S and also the **1122334**. The some\_header\_file block can be any number of lines but always ends with **}** 
So i am trying to grab exactly 7 digits between the g and the S for all the lines from the "Keyword" till the "}" for that specific header.

this is what i used:

```
    FirstSevenDigitPart = str(re.findall(r"Keyword\s%s.*\n.*XYZ\s[gd]([0-9]{7})[A-Z][0-9]{7}.*\}"%variable , str(File) , flags=re.MULTILINE))

```

but unfortunately it does not return anything.. just a blank []
what am i doing wrong? how can i accomplish this?
Thanks in advance.