I'm trying to match some text based on a query that the user inputs. After encountering some issues, I found out this rather odd behaviour of String.indexOf
that I simply cannot understand:
If I try to match a query without diacritics against a string with diacritics, it works: (not sure why)
"brezzel cu brânză".indexOf("bra")
11
But matching the same string with another letter after it, doesn't work:
"brezzel cu brânză".indexOf("bran")
-1
(tested both in Chrome & Firefox, same behaviour)
Is this a documented behaviour that I'm unaware of or what exactly is happening here?