How do i replace multiple characters in a string using vb.net

I want to replace multiple characters in a string.
presently im doing this shown in code.

I want to be able to replace the string with multiple known chars like, "<b>" ,"</b>", "<p>", <br> with empty string "".
Please suggest with code.
Dim txtVal  as String
txtVal= txtVal.Replace("<BR>", "")

Open in new window

nirisanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HainKurtSr. System AnalystCommented:
try this
Dim txtVal  as String
txtVal= txtVal.Replace("<BR>", "").Replace("<b>","").Replace("</b>","")...

Open in new window

0
HainKurtSr. System AnalystCommented:
or
Dim txtVal  as String
txtVal= txtVal.Replace("<BR>", 
txtVal= txtVal.Replace("<b>","")
txtVal= txtVal.Replace("</b>","")
...

Open in new window

0
nirisanAuthor Commented:
thanks for your reply, but is possible to put in through a loop and give toReplace parameters.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

nirisanAuthor Commented:
thanks for your reply, but is it possible to put it in a loop and give toReplace parameters?
0
Kumaraswamy RCommented:
0
appariCommented:
try like this

        Dim a As String = "<br>test<b>wew><</b>wewewew</br><i>wewe</i>", a1 As String
        Dim strReplace As String() = {"<br>", "</br>", "<b>"}
        a1 = String.Join("", a.Split(strReplace, StringSplitOptions.None))
0
HainKurtSr. System AnalystCommented:
something like this
    Public Shared Function MultiReplace(ByVal s As String, ByVal r As String, Optional ByVal w As String = "") As String
        Dim str As String = s
        For Each i As String In r.Split(",")
            str = str.Replace(i, w)
        Next
        Return str
    End Function

use like

str = MultiReplace(str, "<br>,<BR>,</b>,<i>,</i>,</br>", "")

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nirisanAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.