FUNCTION::NGROUPS(3stap)
π FUNCTION::NGROUPS π
okay bestie, we're in the 3stap manual β the SystemTap Tapset Reference situation β and this little cutie is a function, so let's get into it π«Ά
β¨ NAME β¨
function::ngroups β Number of subexpressions in the last match. literally that's the whole job. she's niche but she's iconic π
πΈ SYNOPSIS πΈ
ngroups:long()
π ARGUMENTS π
None. no arguments, no notes, she takes nothing from you π
π¦ DESCRIPTION π¦
So ngroups returns the number of subexpressions from the last successful use of the =~ regex matching operator. that's it. that's the vibe check β¨
Now here's the part you gotta hear, no cap: this number includes subexpressions that are present in the regex but did not match any string. so if you're like "wait, that group didn't match anything, why is she counted" β because that's just how it is, bestie π for example, given the regex "a|(b)", the subexpressions will count the group for (b) regardless of whether it matched a string or not. counted anyway. she said inclusivity periodt π
β οΈ and be careful: it throws an error if the last use of =~ was a failed match. so like... if the match flopped, don't come asking her for a number, she will simply scream at you. main character energy but make it hostile π
π SEE ALSO π
tapset::regex(3stap)
and that's the whole page, you ate it π this was the SystemTap Tapset Reference, version note dated September 2026 β mwah, go slay some regexes, ily π§πβ¨
π¦ where this page comes from
- centos-stream 10: systemtap-client 5.6-3.el10 Β· GPL-2.0-or-later AND GPL-2.0-only AND BSD-3-Clause AND LGPL-2.1-only AND GFDL-1.2-or-later AND BSD-2-Clause
- centos-stream 9: systemtap-client 5.6-3.el9 Β· GPL-2.0-or-later AND GPL-2.0-only AND BSD-3-Clause AND LGPL-2.1-only AND GFDL-1.2-or-later AND BSD-2-Clause
- fedora 43: systemtap-client 5.6-1.fc43 Β· GPL-2.0-or-later AND GPL-2.0-only AND BSD-3-Clause AND LGPL-2.1-only AND GFDL-1.2-or-later AND BSD-2-Clause
- fedora 44: systemtap-client 5.6-1.fc44 Β· GPL-2.0-or-later AND GPL-2.0-only AND BSD-3-Clause AND LGPL-2.1-only AND GFDL-1.2-or-later AND BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms