Slack User Mention
Match Slack user mentions in their raw form <@U01234ABC> as delivered by the Events API.
Try it in RegexPro →Available in
JavaScript / ECMAScript code
const re = new RegExp("<@U[A-Z0-9]{8,}>", "g");
const input = "cc <@U01234ABC> please review";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).
Python (re) code
import re
pattern = re.compile(r"<@U[A-Z0-9]{8,}>")
input_text = "cc <@U01234ABC> please review"
for m in pattern.finditer(input_text):
print(m.group(0))Stdlib `re` module — no third-party dependency. Works on Python 3.6+.
Go (RE2) code
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`<@U[A-Z0-9]{8,}>`)
input := `cc <@U01234ABC> please review`
for _, match := range re.FindAllString(input, -1) {
fmt.Println(match)
}
}Uses `regexp.MustCompile` (panics on bad patterns at startup) and `FindAllString` for all matches.
Pattern
<@U[A-Z0-9]{8,}> (flags: g)Raw source: <@U[A-Z0-9]{8,}>
How it works
Examples
Input
cc <@U01234ABC> please reviewMatches
<@U01234ABC>
Input
pinged <@UABCDEF123GH> earlierMatches
<@UABCDEF123GH>
Input
no mentionsNo match
—Common use cases
- •Slack bot payload parsing
- •Notification auditing
- •@mention frequency analytics
- •Channel migration tooling
Related patterns
AWS ARN (Amazon Resource Name)
IdentifiersMatch AWS ARNs (Amazon Resource Names) across commercial, China, and GovCloud partitions.
AWS S3 Bucket Name
IdentifiersValidate AWS S3 bucket names per the standard naming rules: 3–63 chars, lowercase, alphanumeric + dots + hyphens.
Docker Image Tag
IdentifiersMatch Docker image references with an explicit tag — e.g. nginx:1.21, mycorp/service:v2.3.1.
Git Commit SHA
IdentifiersMatch Git commit hashes, both short (7 chars) and full (40 chars) forms.