How to get the length of text found with CurrentCulture?

Heiko 1,216 Reputation points
2024-07-26T11:23:17.18+00:00

Suppose I have a text "MaxGroßenIsHere". CurrentCulture is set to "de-DE" in my app. German has the character ß, which can often be written as ss, especially in computers. Therefore, "MaxGroßenIsHere".IndexOf("grossen", idx, StringComparison.CurrentCultureIgnoreCase) returns 3, which is correct.

Now I would like to highlight the text found in my app in color. Unfortunately, I only know the length of the text I am looking for, but not the length of the found text. That's why the I in "MaxGroßenIsHere" is also highlighted and the search for any further text starts with "sHere" instead of "IsHere".

It is a UWP app.

How can I determine the length of the text found?

Universal Windows Platform (UWP)
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,524 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,654 questions
{count} votes