function extract_action_and_args($string) {

    if ('' === $string) {
      return array('index', array(), NULL);
    }

    // find optional file extension
    $format = NULL;
    if (preg_match('/^(.*[^\/.])\.(\w+)$/', $string, $matches)) {
      list($_, $string, $format) = $matches;
    }

    // TODO this should possibly remove empty tokens
    $args = explode('/', $string);
    $action = array_shift($args);
    return array($action, $args, $format);
  }