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 19
(9,689 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 19
(9,681 Views)
Message 3 of 19
(9,671 Views)
Solution
Accepted by topic author 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 19
(9,660 Views)
Solution
Accepted by topic author hiNI

Easyer with string functions.

 

space 2 char.png

 

Ben64

Message 5 of 19
(9,649 Views)

AddStringSpaces.png

 

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

Message 6 of 19
(9,615 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 19
(9,516 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 19
(9,506 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 19
(9,501 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 19
(9,472 Views)