Check to see if a string is the start part of a word in a longer string.
BOOL is_str_match_begin_of_word( LPCSTR lpcszStart, LPCSTR lpcsz, int * p_nIndex = NULL )
- [input] start string
- [input] string to search
- [output] the character index in lpcsz where lpcszStart was found, or -1 if not found.
TRUE if a match is found, otherwise FALSE.
int index = 0;
string substr = "Sur";
// Change "Sur" to "ADD" or "/del" to see different result
bool bRet =is_str_match_begin_of_word(substr, "add/delete Surface x-axis", &index);
printf(" \"%s\" is the start of a word and locates in string at the %d character \n",substr,index);
printf("Match failed \n");
checks to see if lpcszStart is the start of of a 'word' in lpcsz. A word starts at the start or after a space, / or -, \t, \n, (, etc.
For the function 's input parameters ,lower case char in lpcszStart will match upper case char in lpcsz,however upper case char in lpcszStart will not match lower case char in lpcsz.So callers should make lpcszStart as lower case char sets to make function fully case insensitive.
If lpcsz = "word1 add/delete Surface x-axis", then "word", "add", "delete" "sur" "axis" "x" are all matching the start of a word in lpcsz,but "face" in "Surface" is not the start of a word, nor is "/delete" or "-axis". Also, "deLete" will not match because is_str_match_begin_of_word is not fully case insensitive.
Header to Include