How-to · Hoopla
Use capture groups in Slack patterns to extract values
Use named regular expression capture groups in Slack patterns to pull values into metric updates or newsflash messages.
This article is for advanced users of the Slack Pattern feature. If you aren’t familiar with regular expressions, try using simple Slack patterns first.
Why use a capture group?
Section titled “Why use a capture group?”In a regular expression, a capture group is an easy way to extract part of the matched pattern from your Slack message. You can either:
-
Set a metric value to the resulting extracted value, or increase/decrease a metric value by the extracted value.
-
Insert the extracted value into a newsflash message template.
To specify a named capture group, you place parentheses around the section of the regular expression that you want to capture and provide a name. Then reference the extracted value using {!name} syntax.
Example
Section titled “Example”The Product team here at Hoopla announces deployments in Slack like this: Sprint 73 has been deployed to Production at 10:05am.
We want to send kudos to them each time they deploy by creating a Pattern to trigger a newsflash:
-
In the pattern section, we specify [Ss]print\s(?<release>\d+).*Production. The (?<release>\d+) portion enclosed in parentheses will match the numbers after the word sprint or Sprint and save the values under the name release.
-
In the newsflash message template, we can then reference the matched numbers such as “Thank you Product Team for releasing version {!release}”.
Related articles
Section titled “Related articles”- Automate with Slack patterns in Hoopla Set up Slack patterns so the Hoopla Bot triggers a newsflash or updates a metric when chosen words appear in Slack.
- Slack pattern examples for Hoopla Use example Slack patterns and regular expressions to trigger newsflashes or update metrics, from team kudos to captured sales amounts.
Still having trouble?
Email our support team.