LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parsing strings.

I have this string as below:
0xABCDEFAB #LADKJF
0XAABBCCDD #ADKF
0XAABBCCDD

How can I strip out everything
except for the hex numbers, ie.:
ABCDEFAB
AABBCCDD
AABBCCDD

I've tried it for the whole afternoon.
But no luck. Can anyone help?

Thanks,
Van
0 Kudos
Message 1 of 9
(3,801 Views)
Van626 wrote:

> I have this string as below:
> 0xABCDEFAB #LADKJF
> 0XAABBCCDD #ADKF
> 0XAABBCCDD
>
> How can I strip out everything
> except for the hex numbers, ie.:
> ABCDEFAB
> AABBCCDD
> AABBCCDD
>
> I've tried it for the whole afternoon.
> But no luck. Can anyone help?

Hmm, "Spreadsheet string to Array" with as separator. Then "Scan
From String" with format string "0%[xX]%x". This will as second
parameter actually return an 32bit integer, representing the value of
the hexadecimal string.

Included image shows two possible ways actually. Watch out to enable "\
code Display" for the string constants.

Rolf Kalbermatter
Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 9
(3,799 Views)
Thank you Rolf,

You came through for me again.
Much appreciated.

Van
0 Kudos
Message 3 of 9
(3,799 Views)

I have a simular problem that I have been working on for a couple days. I have a string that looks like this

+7.50000000E+01 F,101,+7.50000000E+01 F,102,+7.50000000E+01 F,103,+7.50000000E+01 VDC,104

I want to search the string for a channel number (i.e. 102 ect.) an parse  the reading (+7.50000000E+01 F) less the (F) convert from fract/exp string to number and place it into a 1D array. I have tied the example "extract numbers.vi" and was able to get all the number out of the string but it did't preserve the exp values i.e. it read 7.5 instead of 75.

I'm greatful for any help,

jb112454

 

0 Kudos
Message 4 of 9
(3,614 Views)
The attached vi proposes two different solutions. Hope one will fit your needs
Chilly Charly    (aka CC)
0 Kudos
Message 5 of 9
(3,600 Views)
That works great. I didn't realize that you could do that so simply. I need to do more programming not just when we need something. Again thanks so much. jb112454
0 Kudos
Message 6 of 9
(3,580 Views)

Hi

 

I'm trying to parse a string and seperate it into 

 

String

Number

String

 

The only problem is that the output is not delimited by a special character (, ; : ! - _ or anything of the sort).

 

An example would be 

B43F

whereas another example would be J

I could also have 102443H

and so on...

 

 

The amount of chars is random so is the offset. So basically, is there a function that can scan a string and differrentiate a number from a string.

 

I've tried the scan function

e.g

B43F

With Scan function and %s I guess, B43F

e.g

43F with Scan function and (double) I get 43 and F. This works!

 

Thanks again!

 

 

0 Kudos
Message 7 of 9
(3,094 Views)

Use %[^0-9]%d%s for your format.  The %[^0-9] takes a string up until, but not including, a decimal character.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 9
(3,077 Views)

Thanks.

 

I'll try that!

 

I was reading up on those format strings but couldn't quite understnad how to use it.

 

0 Kudos
Message 9 of 9
(3,072 Views)