I have the following string:
CHECKING % x j1 (test1^3) @ phi=0 j2 (test2/3) @ phi=1 j3 @ phi=2 j1 (test1^3) @ phi=2 j2 (test2/3) @ phi=3 j3 @ phi=5
CHECKING % x ab (test1^3) @ phi=0 cde (test2/3) @ phi=1 fg @ phi=2 hij (test1^3) @ phi=2 kl (test2/3) @ phi=3 mn @ phi=5
I would like to get all the j1
, j2
and j3
as well as the ab
, cde
... so everything in front of the brackets or the @
sign respectively, but somehow I cannot make it work. Does someone have an idea for a regex?
Here is what I have tried:
([a-zA-Z_]+[0-9]{0,4})\s+\(.{0,9}\)\s+\@
which gives:
j1 j2 j1 j2 ... ab cde hij kl
But it does not match the j3
, fg
and mn
, how can I include the (...)
term only if appearing?