How to break up the string into smaller strings.

I am using VB

I have the following string which I want to break it up on <br/>

Dim s As String "cat dog <br/> red green <br/> car box <br/> "

Than I have used a split method

Dim s1Temp() As String = s.Split("<br/>")

** current Output: - wrong**

"cat dog"
"br/> red green"
"br> car box"

**I want the following outPut: - correct **

"cat dog" 
"red green"
"car box"

any idea why I am getting the wrong output?

I guess you first have to remove the <br/> tingies from your string.

there has to be <BR/> in strings

Dim s As String "cat dog <br/> red green <br/> car box <br/> "

thats why i need to break it

You can only split on a charcter I think. So you need to replace "<br/>" with say "," and then you split the string, like:

Dim s As String = "cat dog <br/> red green <br/> car box <br/> "
        Dim s2 As String = ""
        s2 = s.Replace("<br/>", ",")
        Dim s3() As String
        s3 = s2.Split(","c)
        For Each st As String In s3
            Debug.Print(st)
        Next

Just as Minimalist has said. Or another way is to now use the .Trim("br>") to remove the br> or use the replace as well like . Replace("br>","") at your code you posted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.