kconfig: refactor pattern matching in STRING state