is_str_match_begin_of_word

 

Description

Check to see if a string is the start part of a word in a longer string.

Syntax

BOOL is_str_match_begin_of_word( LPCSTR lpcszStart, LPCSTR lpcsz, int * p_nIndex = NULL )

Parameters

lpcszStart
[input] start string
lpcsz
[input] string to search
p_nIndex
[output] the character index in lpcsz where lpcszStart was found, or -1 if not found.

Return

TRUE if a match is found, otherwise FALSE.

Examples

EX1

void is_str_match_begin_of_word_ex1()
{
        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);
        if(bRet)
          printf(" \"%s\" is the start of a word and locates in string at the %d character \n",substr,index);
        else
          printf("Match failed \n");              
}

Remark

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.

See Also

is_str_match_begin

Header to Include

origin.h

Reference