Use regex to match var names, add some tests for it