Question 1: The character class [a-zA-Z0-9] matches any letter or any digit.
Question 2: The pattern [a-zA-Z][a-zA-Z0-9]* matches any Pascal identifier (a sequence of one or more letters and/or digits, starting with a letter).
Question 3: The pattern [a-zA-Z_][a-zA-Z0-9_]* matches any C identifier (a sequence of one or more letters and/or digits and/or underscores, starting with a letter or underscore).
Question 4: The pattern ([a-zA-Z_][a-zA-Z0-9_]*[a-zA-Z0-9])|[a-zA-Z] matches any C identifier that does not end with an underscore.
NOTSPECIAL [^\n\"\\]
public static int count; %% QUOTE [\"] NOT_QUOTE_OR_NEWLINE [^\"\n] %x QUOTED_STR_STATE %% <YYINITIAL>{QUOTE} { BEGIN(QUOTED_STR_STATE); count = 0; } <QUOTED_STR_STATE>{NOT_QUOTE_OR_NEWLINE}* { // do nothing } <QUOTED_STR_STATE>{QUOTE}{QUOTE} { Counter.count++; } <QUOTED_STR_STATE>{QUOTE} { BEGIN(INITIAL); return Counter.count; }