2

i am having a string like ~AS DF~GHJ~K LE~RTYUVD~FE~GRF E~SRRRTR EDC~XCE

i want the string between "~" like

AS DF

GHJ

K LE

RTYUVD

FE

GRF E

SRRRTR EDC

2 Answers 2

2

You can try to use Split() function to split input string by tilde (~). Then, since you only interested in substrings between tilde, skip the first and last item in the split result :

Dim splitResult = "~AS DF~GHJ~K LE~RTYUVD~FE~GRF E~SRRRTR EDC~XCE".Split("~")
For Each r As String In splitResult.Skip(1).Take(splitResult.Length - 2)
    Console.WriteLine(r)
Next

Result :

enter image description here

We skip the first item because it only has tilde at the right side

first item~.....

and we skip the last item because it only has tilde at the left side

.....~last item
Sign up to request clarification or add additional context in comments.

Comments

0

Try like this

Method 1:

Dim s As String = "~AS DF~GHJ~K LE~RTYUVD~FE~GRF E~SRRRTR EDC~XCE"

' Split the string on the backslash character
Dim parts As String() = s.Split(New Char() {"~"c})

' Loop through result strings with For Each
Dim part As String
For Each part In parts
    Console.WriteLine(part)
Next

Method 2:

Dim s As String = "~AS DF~GHJ~K LE~RTYUVD~FE~GRF E~SRRRTR EDC~XCE"
Dim words As String() = s.Split(new String() { "~" }, 
                                        StringSplitOptions.None)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.