I am writing a python script which requires to strip all the methods having a particular syntax from a source file.
Suppose I have some methods in a source file which goes like.
fn difflml(args)[
if [
--blah
]
[ var ]
] -- END OF THE METHOD
--Othed method starts and stuffs
Can I strip these style methods from the source file using regex.
I dont know how to keep a count on [ and ] so as to strip the whole method .
What I was thinking was to keep a count on [ and ] ,incrementing on [ and decrementing on ] and print when the count is 0 .
As I am fairly new to regex , I am not sure if this can be done in the regex itself .
("(.*?)\\[.*\\]")