LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parsing out non-numeric characters in a string

Solved!
Go to solution

The InRange? led is off meaning that the two first values are not in the range defined at index 0 and 1 of the lower limit input and were coerced (you set index 2 to -150 but index 0 and 1 are probably at the default value of 0). Also, the upper limit should be included (right click the function and select include upper limit). The code I posted is unfinished, I only included the limit check for the first block of data.

 

Ben64

0 Kudos
Message 41 of 70
(1,669 Views)

Update:

I took the range checking portion off the code and it worked fine, so I guess the error is somewhere in that section. But I am not really sure what that section of code is doing, so I can't really debug it..

Also, is there a way to check if multiple decimal's or negative signs are used? Or if a non-alphabetic character was accidently put in between numbers for an element?


Thanks,

SM

0 Kudos
Message 42 of 70
(1,668 Views)

regex_BD.png

 

Here's a way to check each element.  The result will be an empty string if it's malformed.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 43 of 70
(1,659 Views)

Jim,

 

Thanks for the replies. But I would like to parse out any bad data, not just make it 0. If this is possible, which Ben has showed it is.

 

Thanks,

SM

0 Kudos
Message 44 of 70
(1,656 Views)

@SteMob wrote:

Jim,

 

Thanks for the replies. But I would like to parse out any bad data, not just make it 0. If this is possible, which Ben has showed it is.

 

Thanks,

SM


What exactly does that mean?  If the data is bad enough, the results aren't going to be good enough to mean anything.  It would be like me telling someone "blah blah blah",  "Oh well you know what I meant.".  You either have good data or bad data, and you are trying to take bad data and guess what the good data is supposed to be.  There is no super algorithm that is going to guess what the good data would be when you have an unlimited number of things that could go wrong.  Just return a 0 and report that the data is bad.

0 Kudos
Message 45 of 70
(1,649 Views)

Raven,

 

Right, I understand that, but I would like to parse out as much as possible, at least for the more common errors like a space or too many negative signs or something. After those have been addressed, then I will just return 0 if some more advanced errors are encountered.

 

Thanks,

SM

0 Kudos
Message 46 of 70
(1,642 Views)

Not to beat a dead horse, but you know you could've knocked out that data entry app in less time than it's taking you to figure out this RegEx stuff.

 

It never hurts to go to your lead with an idea that might make it easier for everyone else.  Just be respectfull and don't be a bully about it.

 

The worst they could so is say somethinbg like, "Well, we can't do it that way because customer requirements say blahblahblah", or something like that, and you at least gain more knowledge about how your little piece fits in with all the others.

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 47 of 70
(1,620 Views)

Bill,

 

What do you mean by "data entry app"?


Thanks,

SM

0 Kudos
Message 48 of 70
(1,602 Views)

What would be some additional stuff to add to the RegEx or Search And Replace Pattern such that I could parse out any extra decimal place (such as 123...456) or extra negative signs (such as ---123) or extra tilde's (such as [123~~~456~789] )?

Attached is a screen shot of my current code.

 

Thanks,

SM

0 Kudos
Message 49 of 70
(1,591 Views)

Way back on the bottom of page three, I uploaded a snippet that contained the seed for a possible data entry application that would eliminate the possibility of command syntax error, but you replied that the powers that be wanted it done the way you had described it, so I didn't push it any further.

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 50 of 70
(1,588 Views)