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

# [NAME](#NAME)

function::matched - Return a given matched subexpression.

# [SYNOPSIS](#SYNOPSIS)

```


    matched:string(n:long)
```

# [ARGUMENTS](#ARGUMENTS)

*n*

index to the subexpression to return. 0 corresponds to the entire regular expression.

# [DESCRIPTION](#DESCRIPTION)

returns the content of the n'th subexpression of the last successful use of the =~ regex matching operator. Returns an empty string if the n'th subexpression was not matched (e.g. due to alternation). Throws an error if the last use of =~ was a failed match, or if fewer than n subexpressions are present in the original regexp.

# [SEE ALSO0](#SEE_ALSO0)

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

September 2026 SystemTap Tapset Reference Ver

---

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