RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Gcode Signed Floating Point Number
Expression
(?<=((\s|\n)[XYZABCIJKxyzabcijk]))-?((\d*\.\d+)|(\d+\.\d*)|(\d+\.\d+))(\s|\n)
Description
some machines use multiples of .0001 inch, and some use whole inches if there is no decimal point. This can lead to expensive crashes of machines. It is good practice to have a decimal point in most of our numbers, Everything else is a potential error. I may need to add a \r to the (\s|\n) area on windows, but I don't know. It will be invalid gcode to start the program with X.5 without something like a G01 in front of it, So I didn't put any special consideration to the beginning of the file because There should always be an M command at the end and something else beginning This is probably overkill back detecting the preceding character, as my syntax highlighter will likely use those characters to start a mode, and end on a space, so my single character will be validated for me before hand.
Matches
X2.5 | Y.5 | Z2. | A5335332.3533 | B-.2 | C-5. | I-42.53
Non-Matches
| . | Y. | 2.4. | ..2 | 2 | 6434 | -. | - | 6-3.4 | . | 2.4. | ..2 | 2 | 6434 | -. | - | 6-3.4 | YY2.4 | 2.5Y24 | Y2Y24.5 | G01 | G02
Author Rating: Not yet rated. Aaron Peterson
Source Aaron Peterson
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials