Link to home
Start Free TrialLog in
Avatar of nirisan
nirisan

asked on

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

Avatar of HainKurt
HainKurt
Flag of Canada image

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

Open in new window

or
Dim txtVal  as String
txtVal= txtVal.Replace("<BR>", 
txtVal= txtVal.Replace("<b>","")
txtVal= txtVal.Replace("</b>","")
...

Open in new window

Avatar of nirisan
nirisan

ASKER

thanks for your reply, but is possible to put in through a loop and give toReplace parameters.
Avatar of nirisan

ASKER

thanks for your reply, but is it possible to put it in a loop and give toReplace parameters?
Avatar of Kumaraswamy R
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))
ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nirisan

ASKER

Thanks!