updated construction of DFS from regexp