LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

remove spaces from string

Hello,
 
I have a string in the following format:
 
01 04 81 04 91 04 14 32
 
I would like to remove the spaces such that the resultant string would be:
 
0104 8104 9104 1432
 
Can you please help me accomplish this.
 
Thanks,
hiNi 
0 Kudos
Message 1 of 19
(16,342 Views)

Hi hiNi

you can transform your data to Byte array and run through a for loop. See the attachemt for an example.

Mike

Message 2 of 19
(16,336 Views)
Hi hiNI,

make a loop, feed the string to a shift register, in the loop you delete the (i*i4+1)th character until (i*4+1)>length_of_string...
arghh-the math needs some tweaks and I have to leave Smiley Mad


Message Edited by GerdW on 02-11-2008 05:53 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 19
(16,337 Views)

Sooo... it seems you only want to remove the odd numbered spaces. right?

To remove all spaces, just do a global replace using "search and replace string" and replace "space" with  and empty string. 😉

Message 4 of 19
(16,335 Views)
Try this.  It converts the string to a byte array and then decimate and interleave array functions are used to remove every other space.
Randall Pursley
0 Kudos
Message 5 of 19
(16,309 Views)
THANK YOU all for your recommendations.  You have solved my dilema!!!
 
Sincerely,
hiNi.
0 Kudos
Message 6 of 19
(16,297 Views)

Hello MikeS81,

When I tried to put in a longer string:

01 04 81 04 91 04 14 32 00 00 02 3F 20 00 00 00 2D FF A0 00 10 00 04 00 00 17 07 30 07 75 01 A1 07 93 00 10 1F CE 01 F9 1C 95 01 A4 00 0D 1F F2 00 1D 3E 67 04 40 3B BA 01 A5 3F E0 69 20 00 00 26 22 00 00 DA 9A 2D FD D2 82 26 22 8E CC C8 00 00 B6 3D 68 3F 3B 60 3C AE 12 24 02 3B 00 00 00 2A 28 00 80 00 04 3A FF 01 3C 40 C8 24 92 14 21 00 03 F0 00 08 64 04 0A 00 79 01 00 00 00 00 00 00 F4 00 00

After I ran your Unbenannt 5.vi, this was the output that I got:

0104 8104 9104 1432 0000 0232 0000 0002 0001 0000 4000 0170 7300 7750 1107 9300 1010 1919 5014 0001 2001 3670 4403 0153 0692 0000 0262 2000 0922 8226 2288 0000 6368 3360 3122 4023 0000 0022 8008 0000 4301 3408 2492 1421 0003 0000 8640 4000 7901 0000 0000 0000 4000 0

As you can see, the last word does not correspond to the original word of F4 00.  I looked at your code, however, I can't seem to be able to fix it.  Do you have a quick solution to this problem.

Thanks,

hiNi.

0 Kudos
Message 7 of 19
(16,242 Views)

Hi hiNi,

i change it for you. The only thing to change was the A..F ASCII Code in the Case structure.

Mike

Message 8 of 19
(16,239 Views)
THANK YOU!
0 Kudos
Message 9 of 19
(16,236 Views)
If you don't want to deal with complicated loops, shift registers, built arrays, and case structures, here's a loop-free version.
 
If your array ends in some odd character count, you might need to tweak the result slightly by trimming. Basically, you would calculate the exact final string lenght and use it for the second reshape operation instead of using the product calculation.
 
Modify as needed. 🙂
 


Message Edited by altenbach on 02-13-2008 09:41 AM
Download All
Message 10 of 19
(16,219 Views)