2

Is it possible to replace multiple characters with their corresponding mappings (o -> 0, Z -> 7, B = 8) by only using an input string, search pattern and replacement pattern?

0

1 Answer 1

2

Use a Dictionary(Of String, String) and in a loop String.Replace:

Dim replacementMapper As New Dictionary(Of String, String)
replacementMapper.Add("o", "0")
replacementMapper.Add("T", "7")
replacementMapper.Add("B", "8")
Dim inputString = "This is just an example which is completely pointless."
For Each kv In replacementMapper
    inputString = inputString.Replace(kv.Key, kv.Value)
Next
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.