public function RegexCounter::countGroups in Bibliography Module 7.2
Returns how many groups (numbered or named) there are in the given $pattern
Parameters
string $pattern:
array $namedGroups:
array $numberedGroups:
Return value
int
1 call to RegexCounter::countGroups()
- RegexCounter::count in lib/
msrc-authortool/ src/ Nametools/ RegexCounter.php - Returns how many groups (non-named) there are in the given pattern
File
- lib/
msrc-authortool/ src/ Nametools/ RegexCounter.php, line 39
Class
- RegexCounter
- Regexcounter is a class that counts the expected number of matches for a given REGEX pattern
Namespace
NametoolsCode
public function countGroups($pattern, &$namedGroups, &$numberedGroups) {
$result = $this
->countGroupsIgnoreHellternations($pattern, $namedGroups, $numberedGroups);
$hellternations = $this
->findHellternations($pattern);
if (empty($hellternations)) {
return $result;
}
foreach ($hellternations as $hellternation) {
$count = array();
$pieces = $this
->explodeAlternation($hellternation);
foreach ($pieces as $piece) {
$count[] = $this
->countGroups($piece, $dummy, $dummy);
}
$max = max($count);
$easy = $this
->countGroupsIgnoreHellternations($hellternation, $dummy, $dummy);
$result = $result - $easy + $max;
}
return $result;
}