I would like to check whether a string follows a certain pattern. I tried sscanf, but I do not get the desired result.
The pattern is simple: it consists of:
- the string "while" followed by
- one or more spaces, followed by
- a string made of alpha characters or the underscore character, followed by
- zero or more spaces, followed by
- a colon (':'), followed by
- the newline character ('\n')
Pattern examples:
- while condition_a:
- while test_b :
I tried the following, but it would not check for the column:
sscanf(string, "while %[a-z,_]s %[:]c", test, column);
Would you have any suggestion?
 
     
     
    