LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

insert space character between every two character in a string

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

Message 1 of 18
(5,516 Views)

Re: insert space character between every two character in a string

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?

Message 2 of 18
(5,508 Views)

Maybe this:

Message 3 of 18
(5,498 Views)
Solution
Accepted by hiNI

Re: insert space character between every two character in a string

I was thinking more like this

Spoiler

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

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

Re: insert space character between every two character in a string

Easyer with string functions.

Ben64

Message 5 of 18
(5,476 Views)

Re: insert space character between every two character in a string

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

Message 6 of 18
(5,442 Views)

Re: insert space character between every two character in a string

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

Message 7 of 18
(5,343 Views)

Re: insert space character between every two character in a string

@igagne wrote:

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

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

Ben64

Message 8 of 18
(5,333 Views)

Re: insert space character between every two character in a string

@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

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

Message 9 of 18
(5,328 Views)

Re: insert space character between every two character in a string

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,299 Views)