Why do the same work about 'IndexOfAny' and 'indexOf' function?
FrankLike via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jan 7 06:54:50 PST 2015
I want to know whether the string strs contains
'exe','dll','a','lib',in c#,
I can do : int index = indexofany(strs,["exe","dll","a","lib"]);
but in D: I must to do like this:
findStr(strs,["exe","lib","dll","a"]))
bool findStr(string strIn,string[] strFind)
{
bool bFind = false;
foreach(str;strFind)
{
if(strIn.indexOf(str) !=-1)
{
bFind = true;
break;
}
}
return bFind;
}
phobos 's string.d can add this some function to let the
indexOfAny to better?
Thank you.
Frank
More information about the Digitalmars-d-learn
mailing list