2

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.

For example,

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 delimiter "||" to the next one.

How can I do this?

1 Answer 1

0

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.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.