Slack User Mention in JS
Match Slack user mentions in their raw form <@U01234ABC> as delivered by the Events API.
Try it in the JS tester →Pattern
regexJS
<@U[A-Z0-9]{8,}> (flags: g)JavaScript / ECMAScript code
jsJavaScript
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).
How the pattern works
Literal <@U prefix, then 8 or more uppercase alphanumeric characters (Slack's ID alphabet), closed by >. Matches user IDs regardless of legacy or modern length.
Examples
Input
cc <@U01234ABC> please reviewMatches
<@U01234ABC>
Input
pinged <@UABCDEF123GH> earlierMatches
<@UABCDEF123GH>
Input
no mentionsNo match
—