ohhong2 Posted July 11, 2023 Posted July 11, 2023 hello. I'm asking about the Parse Numbers function that I've seen in lee-mac. This function does not seem to recognize the decimal point when a decimal point of 0 is added. For example, 10.1 is recognized as 10.1, but 10.0 is recognized as 10.0, but not 10.1. How can I get it to literally recognize it as 10.0? Thanks to lee-mac for letting me see the original function. link: http://www.lee-mac.com/parsenumbers.html Function Description This function will extract numbers from a supplied string, returning a list of all numerical values found in the string. There is much ambiguity surrounding what constitutes a valid representation of number in a string. Some functions may permit fractional representations, whilst others include numerical quantities, such as measurements in feet & inches. This function is engineered solely for extraction of numbers represented in decimal format and uses the same rules for validity as the AutoLISP interpreter. code ;; Parse Numbers - Lee Mac ;; Parses a list of numerical values from a supplied string. (defun LM:parsenumbers ( str ) ( (lambda ( l ) (read (strcat "(" (vl-list->string (mapcar '(lambda ( a b c ) (if (or (< 47 b 58) (and (= 45 b) (< 47 c 58) (not (< 47 a 58))) (and (= 46 b) (< 47 a 58) (< 47 c 58)) ) b 32 ) ) (cons nil l) l (append (cdr l) '(())) ) ) ")" ) ) ) (vl-string->list str) ) ) Quote
devitg Posted July 11, 2023 Posted July 11, 2023 (edited) 8 hours ago, ohhong2 said: For example, 10.1 is recognized as 10.1, but 10.0 is recognized as 10.0, but not 10.1. @ohhong2 Please clear out this sentence. And, please upload your sample.dwg Edited July 11, 2023 by devitg add comment 1 Quote
Tharwat Posted July 11, 2023 Posted July 11, 2023 (defun Parse:Numbers+Decimals ( str ) (vl-list->string (vl-remove-if-not (function (lambda ( u ) (< 45 u 58) ) ) (vl-string->list str) ) ) ) (vl-load-com) 1 Quote
Lee Mac Posted July 11, 2023 Posted July 11, 2023 Consider my Split String function, found here. 1 Quote
ohhong2 Posted July 12, 2023 Author Posted July 12, 2023 Thank you so much. I'll check it out again based on your suggestion. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.