regexstep

Regex to capture groups from STEP


I got STEP file (can be read as text) which is written in EXPRESS.

The file looks like:

#14(REPRESENTATION_RELATIONSHIP($,$,#293,#291)REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATION(#12)SHAPE_REPRESENTATION_RELATIONSHIP());
#35=MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION('',#180,888.125521);
#25=ADVANCED_BREP_SHAPE_REPRESENTATION('',(#29),#277);
#186=AXIS2_PLACEMENT_3D('',#270,#230,#231);

I would like to use Regular Expressions to get something like:

Match: REPRESENTATION_RELATIONSHIP($,$,#293,#291); Group1: REPRESENTATION_RELATIONSHIP; Group2: $,$,#293,#291
Match: ADVANCED_BREP_SHAPE_REPRESENTATION('',(#29),#277); Group1: ADVANCED_BREP_SHAPE_REPRESENTATION; Group2: '',(#29),#277

I am new to Regex and came up with this pattern: (\b[A-Z\d]*[_[A-Z\d]*]*)(\((.*?)\))

which works a little, but for example will just match: ADVANCED_BREP_SHAPE_REPRESENTATION('',(#29) instead of ADVANCED_BREP_SHAPE_REPRESENTATION('',(#29),#277)

Thank you for any help.


Solution

  • You might use

    #\d+[(=](\w+)\((.*?)\)[;A-Z]
    

    Explanation

    Regex demo