I am checking for a solution to the following problem.
I have a text sequence as follows and I would like to extract the contents of the square brackets which is closer to the <em>
tag.
[P1/1]0(4)0(5)**[P1/432]** g(5)I(2)d(7)a(8)`<em>`b(5)[P1/4]C(6)e(7)B(8)B`</em>`(9)[P1/5]0(6)i(7)[P1/6]0(1)I(2)[P1/7]0(6)[P1/1]0(1)0(2)[P1/2]E(1)c(2)d(3)a(4)**[P1/3]** 0(1)`<em>`b(2)[P1/4]C(1)e(2)B(3)B`</em>`(4)[P1/5]0(1)
So in the above mentioned text, what I am searching for is [P1/432] and [P1/3].
With regular expression ((.(?!\[.*?]))+?)<em>
, I am not able to get only the contents of the brackets, but everything from [ to <em>
.
Can someone help me ??