tags:

views:

35

answers:

1

I may have a string for example potato in a vb.net application. I want to find all the occurrences of o and convert them to 0, so the desired out is: p0tat0.

I know it can be done by the provided string operations but I need a regular expression in my scenario.

How can this be done?

+3  A: 

No regexp required.

Dim r As String = "potato".Replace('o', '0')

but......

Dim r As String = Regex.Replace("potato", "o", "0")
ChaosPandion
For the regex it's simply `"o"`; no need for the trailing `*` in this case (that actually gives a totally different result).
Ahmad Mageed
@Ahmad - Thanks
ChaosPandion
Thanks a lot, thats exactly what I was looking for.