Skip to content

Regular Expression for GCode #76

@StartAutomating

Description

@StartAutomating

Describe the Desired Expression

A regular expression that can extract out GCode instructions.

Provide some Sample Source Text

; generated by Slic3r 1.3.0 on 2021-10-05 at 19:28:57

; external perimeters extrusion width = 0.44mm (3.38mm^3/s)
; perimeters extrusion width = 0.48mm (7.54mm^3/s)
; infill extrusion width = 0.48mm (10.05mm^3/s)
; solid infill extrusion width = 0.48mm (2.51mm^3/s)
; top infill extrusion width = 0.48mm (1.88mm^3/s)

M127
M118 X38.97 Y23.08 Z3.00 T0
M140 S50 T0
M104 S230 T0
M104 S0 T1
M107
G90
G28
M132 X Y Z A B
G1 Z50.000 F420
G161 X Y F3300
M7 T0
M6 T0
M651
M907 X100 Y100 Z40 A100 B20
M108 T0
M106
; Filament gcode

G21 ; set units to millimeters
G90 ; use absolute coordinates
M73 P0
G1 Z0.400 F7800.000
G1 E-2.00000 F2400.00000
G1 X16.663 Y-10.414 F7800.000
G1 E0.00000 F2400.00000
G1 F1800
G1 X18.593 Y-9.147 E0.27422
G1 X19.941 Y-7.377 E0.53847
G1 X29.941 Y11.623 E3.08846
G1 X30.714 Y14.750 E3.47102
G1 X30.714 Y19.750 E4.06485
G1 X30.317 Y22.025 E4.33907
G1 X29.173 Y24.030 E4.61330
G1 X27.417 Y25.530 E4.88752
G1 X25.257 Y26.345 E5.16175
G1 X24.000 Y26.464 E5.31171
G1 X-6.000 Y26.464 E8.87467

Highlight What you'd like to match

Each line should be matched. If the line starts with a ;, it should be considered a comment. Otherwise, the first word is the instruction and all subsequent words are arguments. Anything after ; on a given line should be considered a comment.

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions