Suppose I have a file filled with text like so:
module combfn1789(clk, i0, i1, i2, i3, o);
input clk, i0, i1, i2, i3;
output o;
wire clk, i0, i1, i2, i3;
wire o;
wire UNCONNECTED788, n_0, n_1, n_2, n_3, n_4;
Q_FDP0I0 o_reg(.CK (clk), .D (n_4), .Q (o), .QN (UNCONNECTED788));
Q_OAI33 g186(.A0 (i2), .A1 (n_1), .A2 (i0), .B0 (n_0), .B1 (n_3), .B2
(n_2), .Z (n_4));
Q_INV g187(.A (i3), .Z (n_3));
Q_INV g188(.A (i0), .Z (n_2));
Q_INV g189(.A (i1), .Z (n_1));
Q_INV g190(.A (i2), .Z (n_0));
endmodule;
module combfn1(clk, i0, i1, i2, i3, o);
input clk, i0, i1, i2, i3;
output o;
wire clk, i0, i1, i2, i3;
wire o;
wire UNCONNECTED0, n_0, n_1;
Q_FDP0I0 o_reg(.CK (clk), .D (n_1), .Q (o), .QN (UNCONNECTED0));
Q_NR04 g59__4296(.A0 (i2), .A1 (i1), .A2 (n_0), .A3 (i3), .Z (n_1));
Q_INV g60(.A (i0), .Z (n_0));
endmodule
I am only interested in a subset of the text, so I am trying to write a python program to isolate the following:
combfn1789
Q_FDP0I0 o_reg(.CK (clk), .D (n_4), .Q (o), .QN (UNCONNECTED788));
Q_OAI33 g186(.A0 (i2), .A1 (n_1), .A2 (i0), .B0 (n_0), .B1 (n_3), .B2
(n_2), .Z (n_4));
Q_INV g187(.A (i3), .Z (n_3));
Q_INV g188(.A (i0), .Z (n_2));
Q_INV g189(.A (i1), .Z (n_1));
Q_INV g190(.A (i2), .Z (n_0));
combfn1
Q_NR04 g59__4296(.A0 (i2), .A1 (i1), .A2 (n_0), .A3 (i3), .Z (n_1));
Q_INV g60(.A (i0), .Z (n_0));
My initial thought was to isolate lines which start with Q_ using re.search. Unfortunately this doesn't work for isolating the module name combfn. I'm not sure how to write a regex that isolates bot the lines that start with Q_ and that module name.