I have a file with following formatted file I need to parse
field_1 {
field_2 {
....
}
field_i_want_to_replace {
....
}
....
}
....
I need a pre-processor in python to parse those files and delete the content of some particular fields. In the above example, the processed file will look like:
field_1 {
field_2 {
....
}
field_i_want_to_replace {}
....
}
....
So the preprocessor needs to locate the particular field "field_i_want_to_replace" and then delete the contents between the brackets. I'm trying to do the following but the regex can't parse the file correctly.
regex = r'(field_i_want_to_replace )\{.*?\}'
print re.sub(regex,'field_i_want_to_replace {}', file_in_string)
Is there sth wrong with the regex I'm using?