NI Home > Community > NI Discussion Forums

LabVIEW

Showing results for 
Search instead for 
Do you mean 
Reply
Active Participant
MrHappyAsthma
Posts: 265
0 Kudos
Accepted Solution

Extract Substring from String

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?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
Active Participant
Taki1999
Posts: 482

Re: Extract Substring from String

Use String Subset with index 5 and length 3.

Active Participant
MrHappyAsthma
Posts: 265
0 Kudos

Re: Extract Substring from String

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? :smileytongue:

 

Either way, thanks!  That did what I was looking for!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!