Python RegEx Question - Grasshopper2024-03-29T10:41:21Zhttps://www.grasshopper3d.com/forum/topics/python-regex-question?commentId=2985220%3AComment%3A1305457&feed=yes&xn_auth=noIt helps a lot if you share y…tag:www.grasshopper3d.com,2015-06-08:2985220:Comment:13056542015-06-08T16:52:27.204ZArendhttps://www.grasshopper3d.com/profile/Arend
<p>It helps a lot if you share your code.</p>
<p>It helps a lot if you share your code.</p> Thanks for the reply, Steve.…tag:www.grasshopper3d.com,2015-06-08:2985220:Comment:13054572015-06-08T15:47:07.100ZWilliam Carrollhttps://www.grasshopper3d.com/profile/WilliamCarroll
<p>Thanks for the reply, Steve. Unfortunately this method won't return True even on strings that GH can successfully cast. The reason for this is that it goes char-by-char and checks if each is a number. That's all good and well until it reaches the decimal point of the number (1.000000), where it rightfully returns False. Here's a screenshot to illustrate this point.…<a href="http://undefined" rel="nofollow" target="_blank"><br></br></a></p>
<p></p>
<p></p>
<p>Thanks for the reply, Steve. Unfortunately this method won't return True even on strings that GH can successfully cast. The reason for this is that it goes char-by-char and checks if each is a number. That's all good and well until it reaches the decimal point of the number (1.000000), where it rightfully returns False. Here's a screenshot to illustrate this point.<a rel="nofollow" href="http://undefined" target="_blank"><br/></a></p>
<p></p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769001956?profile=original" target="_self"><img width="721" src="http://storage.ning.com/topology/rest/1.0/file/get/2769001956?profile=RESIZE_1024x1024" width="721" class="align-full"/></a></p>
<p></p>
<p>I appreciate the reply, and I think I am getting closer to solving the issue. Now I just need to find a Python function similar to isnumeric() that can validate decimal numbers as convertible... It looks like Python's unicode.isdecimal() function may do the trick. I'm not sure though</p>
<p></p>
<p>Still curious about solving this via RegExs, so if there are any RegEx hounds out there, please don't hesitate to edify me.</p> Simple, do a test on your str…tag:www.grasshopper3d.com,2015-06-08:2985220:Comment:13053652015-06-08T15:26:39.047ZSteve Lewishttps://www.grasshopper3d.com/profile/TrevorStephenLewis
<p>Simple, do a test on your strings using isnumeric method to see if numeric or not and only do a numeric operation on those that are:</p>
<p></p>
<p><a href="http://www.tutorialspoint.com//python/string_isnumeric.htm" target="_blank">http://www.tutorialspoint.com//python/string_isnumeric.htm</a></p>
<p></p>
<p></p>
<p>Simple, do a test on your strings using isnumeric method to see if numeric or not and only do a numeric operation on those that are:</p>
<p></p>
<p><a href="http://www.tutorialspoint.com//python/string_isnumeric.htm" target="_blank">http://www.tutorialspoint.com//python/string_isnumeric.htm</a></p>
<p></p>
<p></p> The plot thickens...
Here…tag:www.grasshopper3d.com,2015-06-08:2985220:Comment:13053622015-06-08T15:25:14.016ZWilliam Carrollhttps://www.grasshopper3d.com/profile/WilliamCarroll
<p>The plot thickens...</p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769002360?profile=original" target="_self"><img class="align-full" src="http://storage.ning.com/topology/rest/1.0/file/get/2769002360?profile=RESIZE_1024x1024" width="721"></img></a></p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769002662?profile=original" target="_self"><img class="align-full" src="http://storage.ning.com/topology/rest/1.0/file/get/2769002662?profile=original" width="699"></img></a></p>
<p></p>
<p></p>
<p>Here are two screenshots where I am simply trying to cast one individual item from the list as a number. It doesn't work in the first example yet it works perfectly well in the second…</p>
<p>The plot thickens...</p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769002360?profile=original" target="_self"><img width="721" src="http://storage.ning.com/topology/rest/1.0/file/get/2769002360?profile=RESIZE_1024x1024" width="721" class="align-full"/></a></p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769002662?profile=original" target="_self"><img src="http://storage.ning.com/topology/rest/1.0/file/get/2769002662?profile=original" width="699" class="align-full"/></a></p>
<p></p>
<p></p>
<p>Here are two screenshots where I am simply trying to cast one individual item from the list as a number. It doesn't work in the first example yet it works perfectly well in the second example.</p>
<p>The first screenshot has an item that is coming from the List of strings that CANNOT be cast into numbers. The second screenshot has an item that comes from a List of strings with the same structure as the first example, except these numbers can all be cast into numbers without any errors...</p>
<p>Is it possible that there is an EOL or '\n' character lurking somewhere in the background? And if so...why don't Panels display these characters? Is there some better component available within GH that can display more information about text files? GH in the past hasn't displayed '\t' characters either. Perhaps this type of functionality is already available and I am unaware of it? Or maybe it is a setting within the already existing panel components (e.g. right-click --> display hidden character information)? Or...maybe it is something that should be added to GH 2. Just musing aloud. Either way, any comments are welcomed!</p>