I have to parse some STEP-files (ISO-10303-21) from different CAD-Systems and they are always structured differently. This are the forms that might appear:
#95=STYLED_ITEM('',(#94),#92);
#12 = CARTESIAN_POINT ( 'NONE', ( 1.213489432997839200,
5.617300827691964000, -7.500000000000001800 ) ) ;
#263 = TEST ( 'Spaces must not be ignored here' ) ;
I thought that a regular expression would help me, so I created this one (http://rubular.com/r/EtJ25Hfg77):
(#d+)s*=s*([A-Z_]+)s*(s*(.*)*s*)s*;
This gives me:
Match 1:
1: #95
2: STYLED_ITEM
3:
Match 2:
1: #12
2: CARTESIAN_POINT
3:
Match 3:
1: #263
2: TEST
3:
So the first two groups are working as supposed. But I also need the attributes inside the parantheses like this:
Match 1:
1: #95
2: STYLED_ITEM
3: ''
4: (#94)
5: #92
Match 2:
1: #12
2: CARTESIAN_POINT
3: 'NONE'
4: ( 1.213489432997839200, 5.617300827691964000, -7.500000000000001800 )
Match 3:
1: #263
2: TEST
3: 'Spaces must not be ignored here'
Please help me finding the correct expression for the last group ((.*)
at the moment).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…