HI.... WHY I CANNOT GET THE ANY RESULT IF I AM DECLARING THE PATTERN LIKE THIS?("'if'|'for'|'switch'|'while'|'do'|'case'")
The quote (single or double), does not have special meaning in a regular expression. If you have it in your regex, it will try to match a quote -- just like any letter.
BUT I CAN RECOGNIZE ALL THE WORDS IF I COMPILE LIKE THIS
BUT THEN IT ALSO RECOGNIZES THE WORD double as one of the predicate... why is it so?
The problem is the "do" part of the regular expression, it is matching the first two letters of "double". If you want to specify that the "do" is a whole word, then you also need to specify the word boundaries with the "\\b" pattern -- meaning the word "do" should be "\\bdo\\b".