Match group by index or name.

@param int|string $group

@return string

@throws RegexFailed
509798
public function group($group): string
    {
        if (! isset($this->matches[$group])) {
            throw RegexFailed::groupDoesntExist($this->pattern, $this->subject, $group);
        }

        return $this->matches[$group];
    }
1097814
public function getName($withGroup = false)
    {
        $group = $withGroup ? $this->getGroup() : '';

        $group = $group ? $group . '/' : '';

        return $group . $this->name;
    }
999540
public function reverseTransform($group)
    {
        if(null === $group) {
            return "";
        } elseif ($group instanceof Group) {
            return (string)$group->getId();
        } elseif ($group instanceof ArrayCollection) {
            $result = array();
            foreach($group as $value) {
                $result[] = (string)$value->getId();
            }
            return $result;
        }
        else return "";
    }
360486
protected function convert(
        /*# string */ $name,
        /*# string */ $pattern
    )/*# : string */ {
        // regex
        $groupname   = "\s*([a-zA-Z][a-zA-Z0-9_]*)\s*";
        $grouptype   = ":\s*([^{}]*(?:\{(?-1)\}[^{}]*)*)";
        $placeholder = sprintf("\{%s(?:%s)?\}", $groupname, $grouptype);
        $segmenttype = "[^/]++";

        $result = preg_replace([
                '~' . $placeholder . '(*SKIP)(*FAIL) | \[~x',
                '~' . $placeholder . '(*SKIP)(*FAIL) | \]~x',
                '~\{' . $groupname . '\}~x',
                '~' . $placeholder . '~x',
            ], [
                '(?:',  // replace '['
                ')?',   // replace ']'
                '{\\1:' . $segmenttype . '}',   // add segementtype
                '(?<${1}'. $name . '>${2})'   // replace groupname
            ], strtr('/' . trim($pattern, '/'), $this->shortcuts)
        );

        return empty($name) ? $result : ("(?<$name>" . $result . ")");
    }
952521
public function isAssignedTo($group): bool
    {
        $group = $this->resolveGroup($group);

        return $this->groups()->where('group_id', is_int($group) ? $group : $group->id)->exists();
    }
1333445
public function getGroupField($group = 'all')
    {
        $toExclude = array();
        $toAdd = array();
        if (strpos($group, ',') !== false) {
            foreach (explode(',', $group) as $g) {
                if ($g[0] === '-') {
                    $toExclude[] = substr($g, 1);
                } else {
                    $toAdd[] = $g;
                }
            }
        } else {
            $toAdd = array($group);
        }

        $fields = array();
        foreach ($this->elements as $el) {
            if (!($el instanceof $this->field_class)) {
                continue;
            }
            $elGroup = $el->group();
            if (!in_array($elGroup, $toExclude)
                && (
                    in_array('all', $toAdd)
                    || in_array($elGroup, $toAdd)
                )
            ) {
                $fields[] = $el->short_name;
            }
        }

        return $fields;
    }
1305097
public function getIdNameListByTypeGroup( $type, $group = false, $config = [] ) {

		$config[ 'conditions' ][ 'type' ] 	= $type;
		$config[ 'conditions' ][ 'group' ] 	= $group;

		return $this->getIdNameList( $config );
	}
1355557
public function getConfigFilename($group)
    {
        $conf_files = $this->config->get('conf_files');
        if (!isset($conf_files[$group])) {
            $filename = $this->config['conf_dir'] . '/' . $group . '.json';
            $conf_files[$group] = $filename;
        }
        $this->config->set('conf_files', $conf_files);
        return $conf_files[$group];
    }
1168198
public function getTabGroup(string $group): TabGroup
    {
        if (!isset($this->tabGroups[$group])) {
            throw new \InvalidArgumentException(sprintf('Requested group named "%s" is not found. Did you forget to tag the service?', $group));
        }

        return $this->tabGroups[$group];
    }
822287
protected function checkGroup($group='') {
         if(!empty($group)) {
            $groups = explode(',',$group);
            $_group = array();
            foreach ($groups as $field){
                // 解析成聚合字段
                if(array_key_exists($field,$this->mapFields)){
                    // 需要处理映射字段
                    $field  =   $this->mapFields[$field];
                }                 
                $_group[] = $field;
            }
            $group  =   implode(',',$_group);
         }
        return $group;
    }
316992
public static function getKeys($group)
    {
        self::loadKeys();
        self::$keys[$group] = isset(self::$keys[$group]) ? self::$keys[$group] : [];

        return self::$keys[$group];
    }
907223
public Regex group(String name) {
      return re("(" + (StringUtils.isNotNullOrBlank(name) ? "?<" + name + ">" : StringUtils.EMPTY) + pattern + ")");
   }
467046
public function removeGroup($group)
    {
        if (is_string($group)) {
            // If the group is a string, we'll assume the dev is passing
            // in a DN string of the group. We'll try to locate it.
            $group = $this->query->newInstance()->findByDn($group);
        }

        if ($group instanceof Group) {
            // If the group is Group model instance, we can
            // remove the current models DN from the group.
            return $group->removeMember($this->getDn());
        }

        return false;
    }
662100
public function get($value, $pattern, $group = 0)
    {
        if (!isset($value)) {
            return null;
        }
        
        return preg_match($pattern, $value, $matches) && isset($matches[$group]) ? $matches[$group] : null;
    }
756628
function group($group)
    {
        if (!empty($group))
        {
            self::sql_safe($group);
            $this->group = "group by $group";
        }
        else
        {
            $this->group = '';
        }
    }
276691
public function renderGroup($group)
    {
        if (!isset($this->groups[$group])) {
            return PHP_EOL;
        }

        foreach ($this->groups[$group] as $handle => $data) {
            $assets[] = $this->getGroup($group, $handle);
        }

        return implode(PHP_EOL, $assets);
    }
543687
public static function ungroup($group)
    {
        if (!static::isValidGroupId($group)) {
            return false;
        }
        $gateway_data             = GatewayProtocol::$empty;
        $gateway_data['cmd']      = GatewayProtocol::CMD_UNGROUP;
        $gateway_data['ext_data'] = $group;
        return static::sendToAllGateway($gateway_data);

    }