01-30-2014 12:46 PM
For the life of me I cannot find a function that extracts a substring from an existing string. The closest I could find was SearchSplit String and Replace Substring, but neither of them do what I want.
This is what I want to do:
Assuming a string "Test String", the letters are in positions as follows:
T e s t _ S t r i n g
0 1 2 3 4 5 6 7 8 9 10
Now extact substring from offset 5 to position 7 (Length 3):
Substring = S t r
5 6 7
In Java, for example, you can easily do this using the code below:
String str = "Test String";
String subString = str.substring(5,7);
Is there no simple function to do this in LabVIEW? If not, what's the easiest way to do this?
Solved! Go to Solution.
01-30-2014 12:56 PM
Use String Subset with index 5 and length 3.
01-30-2014 12:59 PM
Oh perfect. Thank you. I was hunting through the Strings Pallette and that one didn't catch my eye. What the world is a "string subset"? Couldn't they just give the String Functions normal String Function names like other languages? 😛
Either way, thanks! That did what I was looking for!
11-01-2016 11:00 AM
Hello all,
It is very strange that i use the function StrSubset('Hello World',3,5) and it prompts an error :
Unknown symbol on line 1 column 1: StrSubset
Anyone has an idea on it?
Thanks in advance.
11-01-2016 12:00 PM
@linaniaina wrote:Hello all,
It is very strange that i use the function StrSubset('Hello World',3,5) and it prompts an error :
Unknown symbol on line 1 column 1: StrSubset
Anyone has an idea on it?
Thanks in advance.
You probably should have started a new thread. Solved threads usually don't see a lot of new activity. Also it's not clear where you're finding this function or which function you are using. The way you wrote it out, it looks like it's not LabVIEW so you may have meant to post this to the LabWindows/CVI board?
11-02-2016 11:00 AM
Dear Taki1999,
Yes, i understand that it is a solved post but the solution seems not working on my side.
I tested the code in the Mathscript tool of Labview 12 and i found the syntax of the function StrSubset() on one Labview pdf document after a long hour of search.
If you can only give me the right syntax please so we can close definitely the topic.
11-02-2016 01:01 PM
You should be using this outside of the Matscript node. You are looking for this function: http://zone.ni.com/reference/en-XX/help/371361H-01/glang/string_subset/ . Easiest way to get to it is go to your block diagram, press Ctrl+Space_bar to get quickdrop, type in "String Subset", and you will find that function. Wire in your string and arguments and you should get your desired results.