Is there a function that can count the number of times the same string shows up in a variable
for example cVariable := "user1/temp/temp"
I Need to count how many times temp shows up in cVariable.
Thanks for any help.
Harvey
Is there a function that can count the number of times the same string shows up in a variable
for example cVariable := "user1/temp/temp"
I Need to count how many times temp shows up in cVariable.
Thanks for any help.
works great. Thanks for the quick esponse. ![]()
Uwe,
I see the -1. So it really returns one more than the token count? Is this a bug?
Maybe we should create a better function:
function TokenCount( cString, cToken )
return ( hb_tokenCount( cString, cToken) -1 )
James
are you saying when it returns 1 it should be 0 and 2 should be 1. The behavior I experenced was just that.
James Bott wrote:Uwe,
I see the -1. So it really returns one more than the token count? Is this a bug?
Maybe we should create a better function:
function TokenCount( cString, cToken )
return ( hb_tokenCount( cString, cToken) -1 )
James
Occurs( <cSubStr>, <cString> ) --> nCountNumAt( <cSubStr>, <cString> ) --> nCount // ct.libRao,
Thanks for the explaination about hb_tokenCount(). However, I still don't understand this example:
msgalert( hb_tokenCount( "user1/temp/temp", "temp" ) -1 ) // Result 2
If we are looking for the number of occurances of "temp" shouldn't hb_tokenCount() return 2? Then the above should return 1, correct?
The Occurs() function seems to be the better and less confusing choice.
Regards,
James
msgalert( hb_tokenCount( "user1/temp/temp", "temp" ) -1 ) // Result 2
If we are looking for the number of occurances of "temp" shouldn't hb_tokenCount() return 2? Then the above should return 1, correct?
The Occurs() function seems to be the better and less confusing choice.
The tokens separated by "temp" are "user1/", "/" and "",