I'm getting StringIndexOutOfBoundsException when I try to reasign the value of a variable. protString = protString.substring(newRPos+1, input.length()); I understand that this is something I would rather not do... but as I don't know the index of newRPos I can't think of another way to iterate.

Thanks

Then also check with if (newRPos < protString.length) . Also, is there any guarantee that input.length() is going to be larger than newRPos, as both of those are indexes (i.e. a start index and an end index) not a start and length, and I don't know how substring reacts if the end index is smaller than the start index..

... I don't know how substring reacts if the end index is smaller than the start index..

API doc states:

Throws: IndexOutOfBoundsException - if the beginIndex is negative, or endIndex is larger than the length of this String object, or beginIndex is larger than endIndex.

API doc states:

Thanks. That was just me being too lazy to look it up myself, and hoping the OP would figure out to do that. ;-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.