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

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 2
Title Test Details 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
Title Test Details Signed Floating Point Number by itself
Expression
^-?((\d*\.\d+)|(\d+\.\d*)|(\d+\.\d+))$
Description
A number with a single decimal point in it. Get rid of the ^'s and $'s if it can bump a word.
Matches
2.5 .5 2. 5335332.3533 -.2 -5. -42.53
Non-Matches
. 2.4. ..2 2 6434 -. - 6-3.4
Author Rating: Not yet rated. Aaron Peterson
   Displaying page 1 of 1 pages; Items 1 to 2

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