FUNCTION::NGROUPS(3stap) A collection of standard strin FUNCTION::NGROUPS(3stap)

# [NAME](#NAME)

function::ngroups - Number of subexpressions in the last match.

# [SYNOPSIS](#SYNOPSIS)

```


    ngroups:long()
```

# [ARGUMENTS](#ARGUMENTS)

None

# [DESCRIPTION](#DESCRIPTION)

returns the number of subexpressions from the last successful use of the =~ regex matching operator.

Note that this number includes subexpressions which are present in the regex but did not match any string; for example, given the regex “a|(b)”, the subexpressions will count the group for (b) regardless of whether it matched a string or not. Throws an error if the last use of =~ was a failed match.

# [SEE ALSO0](#SEE_ALSO0)

[*tapset::regex*(3stap)](/man/enterprise-packages/systemtap/tapset::regex.3stap)

September 2026 SystemTap Tapset Reference Ver

---

Document: function::ngroups(3stap) from systemtap 5.6-r1 (Chainguard OS)
Source: https://sourceware.org/git/systemtap.git
