LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Determine if a string is numeric

I am doing a little project where im trying to get base numbers out of sfcs that may include dashes, numbers, and letters..
 
I pretty much have the rules set out.. but i am trying to determine whether or not certain values after a dash is indeed numeric... this is not a problem until i see something like
001 
 
Im basically taking a string putting it into a convert to number then taking that number and converting it back to a string and then comparing the strings... the convert into number will only giove me a number up to the point it sees a letter thus putting it back into convert to string wont give me the same string i initially had.. this works great until i have something like 12345678-001 ( iknow all the part numbers are 8 digits so it makes it easier to get that 001)  that 001 into a convert to number will only give me 1 not 001... is there anyway around this??
 
 
 
0 Kudos
Message 1 of 5
(4,972 Views)
hi,
 
If you initially have the 001 stored as a unique string, you could just reuse that, but since I don't think that is your problem, why don't you determine how many characters come after the dash in the string and then use string subset to get the substring. You said the part number is always 8 digits, so you could use an offset of 8 (to get you to the 9th character). In the example you gave of 12345678-001, you could determine the length of the total string and subtract the length of the 8 digits + 1 for the dash to find the length of the 001, and then take a substring of that length starting at offset 8. Then you would have a string containing 001, is that what you wanted?
 
Hope that helps,
 
 
Jeff


Using Labview 7 Express
0 Kudos
Message 2 of 5
(4,964 Views)
To format the string into a 3 digit '0' filled string is fairly easy.   Use the Format into String and edit the string to be %03d.  The 0 forces a '0' fill, 3 forces a fill length of 3 characters and d specifies decimal format.  You can create a string constant / control for the format string node and type in %03d.
Visualize the Solution

CLA

LabVIEW, LabVIEW FPGA
0 Kudos
Message 3 of 5
(4,949 Views)
Use Match Regular Expression with the Regular Expression = [0-9][0-9][0-9]. If the Offset Past Match = 3, then you fed it three numeric characters.

Lynn
Message 4 of 5
(4,948 Views)
Thats exactly what was looking for Lynn,  Thank you!
0 Kudos
Message 5 of 5
(4,912 Views)