I have a descriptor and I want to search it for multiple words to see if one of these words are exist or not, How can I do this ?
_LIT(KText,"Good Bad Wrong Right False True Now Later What How");
TBuf<100> buf(KText);
Now I want to search "buf" to see it has (Fasle, Now, Bad) words or at least one of them.
This is the code below I use, But I don't feel it is sufficient :
_LIT(KText,"Good;Bad;Now;Later;Why;What");
TBuf<100>buf(KText);
_LIT(KWord,"Good;Now");
TBuf<100>g_Word(KWord);
TPtrC ptr;
TChar delimiter;
delimiter = TChar(';');
for(TInt ii = 0; ii < 100; ii++)
{
if(KErrNone == TextUtils::ColumnText(ptr,ii,&g_Word,delimiter))
{
TBuf<100> temp;temp.Copy(ptr);temp.LowerCase();
if(KErrNotFound != buf.Find(temp))
{
// here I'm gonna do somet开发者_开发问答hing if there is a match with one or more words in the "buf"
}
}
else
{
break;
}
}
Many thanks in advance.
TDesC has a lot of useful functions. http://library.forum.nokia.com/index.jsp?topic=/S60_3rd_Edition_Cpp_Developers_Library/GUID-CEE609D8-50E3-422D-8FF9-42C25D669E59_cover.html
_LIT16(KFind1,"bad");
TInt index = str.Find(KFind1); /*Will return index if found else returns KErrNotFound*/
精彩评论