views:

201

answers:

3

I have this string that shall come in from another file. The string has maximum length of 102 digits. I need to compare the string with numbers in a pair and delete those from that string.

e.g - 6125223659587412563265... till 102

numbers that compare with this string-

first set - 61

new string = 25223659587412563265

second set - 36

new string = 252259587412563265

and so on. the set of numbers shall go to maximum of 51 pairs = 102, which shall give an end result of string = "" How can i achieve this in a loop?

A: 

this is not answer, this is editing the question. i dont know why but the edit button just vaniashed so i have to edit question here. No duplicates will ever be in this string. and in the end when compares are done, i want to see what numbers are left in pairs.

refer
A: 

Here is a simple solution. You will need to add your pairs to the List(Of String) and also initialize input to the string you want to alter.

Dim pairs As New List(Of String)()
Dim input As String = String.Empty
For Each pair As String In pairs
    input = input.Replace(pair, String.Empty)
Next
gbogumil
A: 
Dim input As String = "6125223659587412563265"
Dim targets As String() = {"61", "36"}

For Each target As String In targets
    input = input.Replace(target, "")
Next
Debug.Assert(input = "252259587412563265")
Sky Sanders