I read some values from MS SQL database and I like to make some operations on string. Here is the code I am using to check if some string starts with another string:
String input = "Основното jавно обвинителство денеска поднесе пријава против БМ (59) од Битола заради постоење основи на сомнение дека сторил кривични дела „тешки дела против безбедноста на луѓето и имотот во сообраќајот“ и „неукажување помош на лице повредено во сообраќајна незгода“";
String subString = "Основното јавно обвинителство";
if (input.StartsWith(subString))
{
Response.Write("OK");
}
However input.StartsWith(subString)
does not return true. Does anybody have an idea why?
The startsWith() method checks whether a string starts with the specified character(s). Tip: Use the endsWith() method to check whether a string ends with the specified character(s).
In C#, StartsWith() is a string method. This method is used to check whether the beginning of the current string instance matches with a specified string or not. If it matches then it returns the string otherwise false. Using foreach-loop, it is possible to check many strings.
The JavaScript startsWith method is used to determine whether a string starts with a character or a particular string. The method returns a boolean true in case the string starts with the specified characters.
The startsWith() method returns true if a string starts with a specified string. Otherwise it returns false . The startsWith() method is case sensitive.
The difference is in the character j
in the position 10: its code is 106 in the input, but in your substring it's 1112 (0x458
- see demo).
Your second j
comes from Unicode page 4
ј 1112 458 0xD1 0x98 CYRILLIC SMALL LETTER JE
It looks the same, but has a different code.
Re-typing j
in the substring
fixes this problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With