StringIndexError some time comes unexpectedly

StringIndexError some time comes unexpectedly.

Does anybody have this type of error? How to deal with it.
I just do the next code to solve the problem, just change the index from 701 to 702 =)). Does anybody suggest other solutions?

try
f=findfirst(“blabla”,page[end-701:end])[1]
return page[1:end-701+f-3]
catch
f=findfirst(“blabla”,page[end-702:end])[1]
return page[1:end-702+f-3]
end

You have to be careful when indexing into strings in Julia. It is important to understand that certain characters can take up more than one index, and therefore errors can occur if you blindly assume that every page[i] is valid.
This section of the manual should help you come up with a solution to your problem: Strings · The Julia Language

1 Like

Thank you so much.