A call to `indexOf()` should take time proportional to the number of symbols it has to pass till it finds the match. So, no, if the match is near to the beginning of the string, it won't take much time.