Well, youYou can simpllysimply use a regexregular expression library and solve that using regular expressions.
theUse expression that solves that is (\w+) and the variable in \1 (or $1 depending on the liblibrary implementation of REregular expressions).