views:

32

answers:

1

i have a string that looks like this - "1AL||9CA||34CO||196WY||..." i want to use a for loop or while loop, in which if i have an integer, it should parse this string and delete the value matching that integer. example for above string

string = "1AL||9CA||34CO||196WY||..." integer = 34

for ... loop

new string = "1AL||9CA||196WY||..."

As you can see the integer matched the integer 34 and deleted from one delimeter "||" to th next one. how can i do this?

A: 

This is what you should do:

First split the string and then store the array.

Now loop through the array and using indexof function check for the integer value in the array element.

Remove that element from the array.

Finally use the Join function to join the elements which is the result you want.

HTH

Raja