开发者

string parse and replace in for loop

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 strin开发者_开发技巧g 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜