LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parsing out non-numeric characters in a string

Solved!
Go to solution

I'm no expert on regular expressions either. In the past I've seen people linking this web site to learn them. It looks like there is a tool there to test them. I hope it helps.

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 11 of 70
(1,795 Views)

Alten,

 

What do you mean by "extra characters"? Yes I will have numeric characters mixed in, I'm trying to parse out the none needed characters (any non-numeric character. These are the only exceptions: negative sign, decimal place, tilde, or brackets).

And of course it fragile, it's a computer program lol 😜


Thanks,

SM

0 Kudos
Message 12 of 70
(1,794 Views)

Thanks Bob,

 

I took a look at that site before, but it didn't really help me since it was reffering to script based programming and not LabVIEW.

 

Thanks,

SM

0 Kudos
Message 13 of 70
(1,792 Views)

@SteMob wrote:

 

What do you mean by "extra characters"? Yes I will have numeric characters mixed in, I'm trying to parse out the none needed characters (any non-numeric character. These are the only exceptions: negative sign, decimal place, tilde, or brackets).

 


What guarantees that all characters that are not part of the valid message are non-numeric?

 

For example what if you receive:

[-50~-150~0]~[0.96593~-0.92957882~0~0]~[1~-1~0~0]~[150~50]

Instead of:

[-50~-150~0]~[0.96593~-0.25882~0~0]~[1~-1~0~0]~[150~50]

 

This would result is something quite different by about a factor of four! 😮

0 Kudos
Message 14 of 70
(1,781 Views)

Looking back at the original post, I have to ask, "Why would there be 'extra' characters in the first place?"  Is the user typing this command into a text box?  I think you would do better to track down the source of the "extra" or "bad" characters and eliminate it.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 15 of 70
(1,778 Views)

altenbach wrote:

What guarantees that all characters that are not part of the valid message are non-numeric?

 

For example what if you receive:

[-50~-150~0]~[0.96593~-0.92957882~0~0]~[1~-1~0~0]~[150~50]

Instead of:

[-50~-150~0]~[0.96593~-0.25882~0~0]~[1~-1~0~0]~[150~50]

 

This would result is something quite different by about a factor of four!

 

REPLY:

Alten,

If the "extra characters" are numeric, we can deal with that on the robot side. But I have to eliminate non-numeric characters on the LV side...

 

Thanks,

SM

0 Kudos
Message 16 of 70
(1,711 Views)

billko wrote:

Looking back at the original post, I have to ask, "Why would there be 'extra' characters in the first place?"  Is the user typing this command into a text box?  I think you would do better to track down the source of the "extra" or "bad" characters and eliminate it.

REPLY:

Bill,

We are generating these targets for the robot using Blender and Python. The targets then get converted into a csv file that we load into LV and send individually to the robot.

0 Kudos
Message 17 of 70
(1,710 Views)

@SteMob wrote:

@billko wrote:

Looking back at the original post, I have to ask, "Why would there be 'extra' characters in the first place?"  Is the user typing this command into a text box?  I think you would do better to track down the source of the "extra" or "bad" characters and eliminate it.

REPLY:

Bill,

We are generating these targets for the robot using Blender and Python. The targets then get converted into a csv file that we load into LV and send individually to the robot.


So if they are being generated "automagically", then the problem is either with the generation or the communications.  The solution is obvious if the error occurs at the generation, of course.  With communications, you should probably develop a method of sending data packets that has some sort of CRC or checksum as mentioned in previous posts.  (What happens if the data is in a valid format but one of the bits got changed in the transmission?)

 

Or is this exercise purely theoretical?  By default, one of the great advantages of generating stuff programmatically is that eliminates human error as a generation issue.  Again, if the programming is incorrect... well then you have bigger problems and shouldn't be trying to correct errors after they occur.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 18 of 70
(1,702 Views)

Bill,

 

Yes they are being generated semi-automatically, but there is still some human hand involved, for multiple reasons. So I still have to have the check in there. We are running the robot for hours on end with a multi thousand line csv file. Can't have the program reading through most of the csv file and then suddenly read a line with a bad character in it and crash the programs...

 

Yes and no on the theoretical... I hope to never need this section of code. But I would rather have it in there and not need it, than to need it and not have it. This will be more of an error handler type thing. So if LV reads a line in the csv file that it is not expecting (bad characters, etc.), then it will jump to a section of code that can parse out the unexpected characters, then output the results.

 

Regardless of why I need the check there, I need the check there. So any suggestions on formatting the Match Regular Expression? Or suggestions for another method?


Thanks for the help,

SM

0 Kudos
Message 19 of 70
(1,700 Views)

@SteMob wrote:

Bill,

 

Yes they are being generated semi-automatically, but there is still some human hand involved, for multiple reasons. So I still have to have the check in there. We are running the robot for hours on end with a multi thousand line csv file. Can't have the program reading through most of the csv file and then suddenly read a line with a bad character in it and crash the programs...

 

Regardless of why I need the check there, I need the check there. So any suggestions on formatting the Match Regular Expression?


Thanks,

SM


Oh, semi-automatically.  I can see why you would want error checking.  I'm not sure this can be done because humans are notoriously able to thwart any kind of error checking.  😉

 

You might start down the path of using ring controls + values to enter your data.  This would at least eliminate syntax errors.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 20 of 70
(1,696 Views)