Search code examples
regexsublimetext3g-code

how to select all instances of value starting with specific character in sublime text


I have a gcode file with over 10000 lines in which each line has a specific z value. It looks something like this:

Z0.9172 A-39607.857 F335.4365
Z0.9171 A-39609.173 F471.9932
Z0.9168 A-39611.023 F334.6937
Z0.9165 A-39612.873 F334.833
Z0.9162 A-39614.723 F334.0549
Z0.9158 A-39616.574 F333.6805
Z0.9156 A-39617.5 F666.9009
Z0.9152 A-39619.352 F333.0177
Z0.9147 A-39621.006 F372.2372
Z0.9142 A-39622.661 F371.2148
Z0.914 A-39623.587 F667.196
Z0.9135 A-39625.441 F331.7536
Z0.9128 A-39627.296 F331.3328
Z0.9122 A-39629.073 F345.2881
Z0.9116 A-39630.66 F387.0251
Z0.9111 A-39632.105 F424.5826
Z0.9105 A-39633.561 F421.2656
Z0.9097 A-39635.321 F348.3452
Z0.9091 A-39636.674 F452.9146
Z0.9084 A-39638.197 F402.1978
Z0.9077 A-39639.741 F396.8941
Z0.907 A-39641.26 F403.1875
Z0.9062 A-39642.709 F422.3053
Z0.9057 A-39643.756 F585.385
Z0.9051 A-39644.953 F511.8211
Z0.9045 A-39646.169 F503.4698
Z0.9038 A-39647.346 F520.4895
Z0.9032 A-39648.469 F545.4137
Z0.9026 A-39649.537 F573.2443
Z0.9017 A-39651.035 F408.8793
Z0.9006 A-39653.028 F307.3789
Z0.8996 A-39654.672 F372.8275
Z0.8986 A-39656.23 F393.2829
Z0.8975 A-39658.081 F331.3421

What I need to do is remove all of the values that start with z, I tried simply selecting z and command and control g to multi select all of them then expanding my selection with the arrow ket to grab all the left over decimal places. The problem is that they don't have all the same amount of decimal places so I end up selecting values I don't want selected.

It seems like maybe regex can do things like this but I'm not familiar with it, any help would be great.


Solution

    1. Press Crtl-H,
    2. check Regular expressions enabled,
    3. in field Find: put Z\d\.\d+,
    4. leave Replace: empty,
    5. click Replace All

    Manual with screenshots here