Cleaned up the variable extraction regex and documented it.