LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

insert space character between every two character in a string

Solved!
Go to solution

Hello,

 

I am trying to put a space between every two characters in an input string.  I only got the VI to work after the first 2 characters.  Can you help me get the space after every two (2) characters?

 

Thanks,

hiNi

0 Kudos
Message 1 of 18
(5,534 Views)

Your input looks suspiciously like a hexadecimal number. Are you sure you need to be passing around strings instead of numbers?

If you really do need to work with strings, why not keep it as strings instead of converting down to bytes?

 

 

0 Kudos
Message 2 of 18
(5,526 Views)
Message 3 of 18
(5,516 Views)
Solution
Accepted by hiNI

I was thinking more like this

Spoiler
string_space.png

There's an extra space at the end which can easily be deleted.

 

Message 4 of 18
(5,505 Views)
Solution
Accepted by hiNI

Easyer with string functions.

 

space 2 char.png

 

Ben64

Message 5 of 18
(5,494 Views)

AddStringSpaces.png

 

Using \V (not vertical whitespace) adds the spaces line by line and ignores the linefeeds.

Message 6 of 18
(5,460 Views)

You can get a little more performance (>10x?) if you don't use build array in a loop and avoid regex

 

Insert spaces_BD.png

0 Kudos
Message 7 of 18
(5,361 Views)

@igagne wrote:

You can get a little more performance (>10x?) if you don't use build array in a loop and avoid regex

 

Insert spaces_BD.png


You will need to pad an extra space at the end of the original string is its lenght is odd.

 

Ben64

0 Kudos
Message 8 of 18
(5,351 Views)

@ben64 wrote:

@igagne wrote:

You can get a little more performance (>10x?) if you don't use build array in a loop and avoid regex

 

Insert spaces_BD.png


You will need to pad an extra space at the end of the original string is its lenght is odd.

 

Ben64


Depends on what's in the requirements doc Smiley Wink

0 Kudos
Message 9 of 18
(5,346 Views)

Just to break the monotony, here's yet another possibility.... 😄

 

 

 

(of course tweaks might be needed if the number of input characters is not even or if the last space is unwanted, for example)

 

 

 

Message 10 of 18
(5,317 Views)