#How to slice string with start and end not start and count?

8 messages · Page 1 of 1 (latest)

cobalt merlin
#

string::substr required start index and count. I only have start index and end index. I cannot find any string method that offer such functionality. Should I implement slice function by myself or is there other way?

solar nacelleBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

cobalt merlin
#

to clarify it more, let say I have this string hello
I want to get ell substring so I do s.substr(1, 3) but instead I got ello (i didn't test it, it probably would return other result but still its not what I want)
Yes I can do s.substr(1,2) to get ell but let say I don't know the count but I know the end index.

#

Ok I think I know how to solve this

#

I can do end - start to get the count. The code would like this:
s.substr(start, end - start)

#

!solved

solar nacelleBOT
#

Thank you and let us know if you have any more questions!

cobalt merlin
#

!close