LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scan from string, inserting . into a string

Solved!
Go to solution

 

Hellow LV'ers

 

Simplified Example

 

I have a string with 3 digits e.g.   input 789

 

 

I would like to use scan string to place a "." between the digits.

 

input 789 output 7.8.9

 

 

How do I set up the scan string to do this?

 

 

Thanks

 

 

0 Kudos
Message 1 of 8
(3,667 Views)

The simple answer is that you can't. Scan from string is not used to insert of format new strings. It is for pulling items out of strings.

 

However, here is an example that does what you want using regular expressions.

 

Insert dots in string.png

 

This example will only work for strings that are three digits long. You could modify it to use a loop which will work for any length string. If you use a loop you will only pick a single digit at a time from the string so your regular expression would be "(\d)".

 

 

 



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 8
(3,659 Views)
Solution
Accepted by topic author crewex

Of course a general solution needs to be more scalable. I don't think we can assume that there are always exactly three numbers, because this was only given as a "simplified example". 😄

 

 

Here is a solution that works for any length string (containing decimal digits exclusively)

 

 

 

(of course you need to ensure that the input is sane and does not contain any illegal characters. not shown, but look at lexical class)

Message 3 of 8
(3,649 Views)

This should work too

 

insert period.png

=====================
LabVIEW 2012


Message 4 of 8
(3,645 Views)

Steve, you are very conflicted at the moment. Having 2010 in the signature and posting a 2011 snippet. 😄

Message 5 of 8
(3,640 Views)

How about now Smiley Very Happy

=====================
LabVIEW 2012


Message 6 of 8
(3,631 Views)

smallest and most versatile!! I love it, thank you as usual mighty altenbach

0 Kudos
Message 7 of 8
(3,613 Views)

You can also use Search and Replace String.vi in regex mode. This seems to be the more versatile way since the input string can contain both text and number. This will insert a dot between every consecutive digits.

 

add dot between digits.png

 

Ben64

Message 8 of 8
(3,606 Views)