Fastest way to determine if a string is contained in another

Public forum to share code snippets, screen shorts, experiences, etc.
FFF
Posts: 1589
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Fastest way to determine if a string is contained in another

Post by FFF »

Again, interesting read, thx.
One caveat i found with indexof
? VAR x := "ABC"
? x:IndexOf("AB")
? x:IndexOf("")

You get (also) "0" back, if by chance/oversight your search string was "lost" prior to searching.
You'll get the same with contains, but in is case, i'd preferred an exception for "Empty". Can't imagine a "useful" search with ""... ;)
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
SHirsch
Posts: 286
Joined: Tue Jan 30, 2018 8:23 am
Location: Germany

Fastest way to determine if a string is contained in another

Post by SHirsch »

Hi Karl,

you should'nt ask if something is 'useful' in the .Net framework. There are many things where you can ask for the use case.
I always look at the docs and don't ask why. I take it as god given or search for something else that is better for my needs.

Stefan

PS: https://docs.microsoft.com/de-de/dotnet ... em_String_
FFF
Posts: 1589
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Fastest way to determine if a string is contained in another

Post by FFF »

Hi Stefan,
God? Oh my God ;)
I had looked at the docs, thx.

BTW, a good sample how automatic translation can fail:
The english doc version has a sample, described:
..." The following example looks for "n" in "animal"
gets in German:
"Das folgende Beispiel sucht nach "n" in "Tier"
Good, that they at least didn't translate the code ;)
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
SHirsch
Posts: 286
Joined: Tue Jan 30, 2018 8:23 am
Location: Germany

Fastest way to determine if a string is contained in another

Post by SHirsch »

oh yeah, i mostly do read the english version. To understand the german version I often have to read it three times to understand what is meant.
User avatar
lumberjack
Posts: 728
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

Fastest way to determine if a string is contained in another

Post by lumberjack »

FFF wrote: Good, that they at least didn't translate the code ;)
Grrr and there all my efforts to code in German fails miserably...
______________________
Johan Nel
Boshof, South Africa
Post Reply