I’m pasting the exact strings that javascript prints:
string: "testare atasament fisier,tip nota - reamintire (1),Diverse,Telefon,Fisier,tip nota Azom" without the ""
substring: "tip nota - reamintire (1)" again without the ""
just writing those “” to show that there are no empty spaces anywhere funny (also checked in the code)
The result of
string.search(substring);
is always -1, how come? which character is messing up the search?
note that i don’t use the names string and substring for the variables in my actual code
It worked for me – using
indexOfyields
search takes a regular expression where indexOf takes a string.
The parenthesis inside of “tip nota – reamintire (1)” act as a group, you would have to escape them for it to match an actual parenthesis.