cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

insert space character between every two character in a string

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

0 Kudos
Message 1 of 18
(3,378 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?

 

 

0 Kudos
Message 2 of 18
(3,370 Views)

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

Maybe this:

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Message 3 of 18
(3,360 Views)
Solution
Accepted by topic author hiNI
08-27-2015 04:09 PM

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

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
(3,349 Views)
Solution
Accepted by topic author hiNI
08-27-2015 04:09 PM

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

Easyer with string functions.

 

space 2 char.png

 

Ben64

--------------------------------------------------
The best way to say thanks is to give kudos!
Message 5 of 18
(3,338 Views)

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

AddStringSpaces.png

 

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

Message 6 of 18
(3,304 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

 

Insert spaces_BD.png

0 Kudos
Message 7 of 18
(3,205 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

 

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

--------------------------------------------------
The best way to say thanks is to give kudos!
0 Kudos
Message 8 of 18
(3,195 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

 

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
(3,190 Views)

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

Just to break the monotony, here's yet another possibility.... Smiley Very Happy

 

 

 

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

 

 

 


LabVIEW Champion Do more with less code and in less time
Message 10 of 18
(3,161 Views)