I have a string which at some point contains the set of characters in the following format [123]
.
What I would like to do is get the characters between []
but the characters in between are never the same length.
How would I go about this in VB.NET?
To extract part string between two different characters, you can do as this: Select a cell which you will place the result, type this formula =MID(LEFT(A1,FIND(">",A1)-1),FIND("<",A1)+1,LEN(A1)), and press Enter key. Note: A1 is the text cell, > and < are the two characters you want to extract string between.
Extracting text between characters in Excel 365 In Excel 365, you can get text between characters more easily by using the TEXTBEFORE and TEXTAFTER functions together. This formula also works nicely for extracting text between two occurrences of the same character.
To extract the text between any characters, use a formula with the MID and FIND functions. The FIND Function locates the parenthesis and the MID Function returns the characters in between them.
Dim s As String = "foo [123]=ro bar"
Dim i As Integer = s.IndexOf("[")
Dim f As String = s.Substring(i + 1, s.IndexOf("]", i + 1) - i - 1)
Dim s As String = "nav[1]=root"
dim result as String = s.Substring(s.IndexOf("[") + 1, s.IndexOf("]", s.IndexOf("[")) - s.IndexOf("[") - 1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With