LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String extract hexadecimal number

Solved!
Go to solution

I have device that returns multi line response where I need to extract hex number in this patten f01a.ad70.db84

 

The hex number will chamge, but will be in same patten (FFFF.FFFF.FFFF)

 

Thanks you.

0 Kudos
Message 1 of 10
(3,870 Views)

Scan From String is your friend. Smiley Wink

 

Hint: %x.%x.%x

Message 2 of 10
(3,867 Views)

Exactly,

 

 

Message Edited by Chris_VH on 03-26-2009 01:43 PM
Chris Van Horn
Applications Engineer
0 Kudos
Message 3 of 10
(3,853 Views)

Both of thank you for your help and point me right deriction.

Because of multi line and muti number, I had to change little bit.

 

Let me know if there is easier way...

 

Thank you again.

 

0 Kudos
Message 4 of 10
(3,844 Views)
There may be an easier way. I don't quite understand what you're doing in your code. What do you mean by "multi line" and "multi number"?  I can understand the "multi line", but I don't get the "multi number". Do you mean you have more than 3 numbers per line? If so, how many. Can you provide a sample file? For multiple lines you can just use the Spreadsheet String to Array function to get your array and auto-index a for-loop.
0 Kudos
Message 5 of 10
(3,823 Views)

Hello smercurio_fc, thank you for help.

I am attaching Test VI. What I was looking for is way to extract hex number; in this case I was able extract IP address that get return in message. This was easy because they are in decimal format, so I made a match pattern “[0-9]+[.][0-9]+[.]+[0-9]+[.][0-9]+” (ie 10.10.10.10). But I wasn’t sure how to make pattern for hexadecimal number, I need to extract MAC Address as well; so I ask the question.

Is there a easy way to make match pattern?

 

Something like [0-9]or[a-f]+[.] [0-9]or[a-f]+[.] [0-9]or[a-f]+[.]

0 Kudos
Message 6 of 10
(3,817 Views)
Solution
Accepted by topic author lvABC

I tried removing all the "enters" with a "space" to make it one line. Then I just kept passing the remaining string through a shift register. Not sure if its more simple, just another way to do it.

 

 

 

Message Edited by Chris_VH on 03-26-2009 04:22 PM
Chris Van Horn
Applications Engineer
Message 7 of 10
(3,800 Views)

Thank you for help.

I was able to just extract the hexadecimal number by have pattern [0-9|a-f]. "[0-9|a-f]+[.][0-9|a-f]+[.][0-9|a-f]+"

This way I don't have worry about if any other data come between ip and mac address.

Thank you again for help.

🙂

0 Kudos
Message 8 of 10
(3,793 Views)

You can also use Match Regular Expression to find your hex string:

 

 

Message Edited by smercurio_fc on 03-26-2009 05:02 PM
Message 9 of 10
(3,786 Views)

Excellent!

Thank you very much

0 Kudos
Message 10 of 10
(3,779 Views)