Get index of first detected space after a certain index in a string

前端 未结 2 1255
栀梦
栀梦 2021-01-17 13:33

In a string to format (mostly to replace chars with different symbols for rendering test on UI), I have to detect % and then skip all chars util first space from this % char

2条回答
  •  终归单人心
    2021-01-17 14:18

    You can get that pretty easily, just grab the index if the first percent sign and then leverage that index to find the first space from there:

    var start = myString.IndexOf("%");
    var spaceIndex = myString.IndexOf(" ", start)
    

    of course the value of myString is the string you represented in your question.

提交回复
热议问题