How to replace text from (abc) to (cba) in vb.net

Example:

here is text

(abc)random text here(cba)

Recommended Answers

All 2 Replies

u mean to say u want to reverse?

See if this helps.

Dim myEntireCoolString As String = "(abc)random text here(cba)" '// your string.
        Dim xiStartIndex As Integer = myEntireCoolString.IndexOf("(abc)") + 5 '// locate the start Index.
        Dim xiEndIndex As Integer = myEntireCoolString.IndexOf("(cba)", xiStartIndex) '// locate the end Index.
        Dim myFoundCoolString As String = myEntireCoolString.Substring(xiStartIndex, xiEndIndex - xiStartIndex) '// extract content.
        myEntireCoolString = myEntireCoolString.Replace(myFoundCoolString, "something here to replace with") '// replace content.
        MsgBox(myEntireCoolString) '// get result.
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.