Regex for Slack Channel Name
Regex Pattern
^[a-z0-9][a-z0-9_-]{0,79}$Valid Slack channel name (lowercase, max 80 chars)
Quick Answer
The regex pattern for slack channel name is `^[a-z0-9][a-z0-9_-]{0,79}$`. Valid Slack channel name (lowercase, max 80 chars). This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.
Test Examples
| Input | Result |
|---|---|
| general | ✓ Matches |
| team-engineering | ✓ Matches |
| project_alpha | ✓ Matches |
| General | ✗ No match |
| #channel | ✗ No match |
| -start-dash | ✗ No match |
| has space | ✗ No match |
Code Examples
javascript
const regex = /^[a-z0-9][a-z0-9_-]{0,79}$/;
const isValid = regex.test(value);python
import re
pattern = r'^[a-z0-9][a-z0-9_-]{0,79}$'
if re.match(pattern, value):
print("valid")ruby
pattern = /^[a-z0-9][a-z0-9_-]{0,79}$/
if value =~ pattern
puts "valid"
endphp
if (preg_match('/^[a-z0-9][a-z0-9_-]{0,79}$/', $value)) {
echo "valid";
}java
String pattern = "^[a-z0-9][a-z0-9_-]{0,79}$";
boolean isValid = value.matches(pattern);Frequently Asked Questions
Related Regex Patterns
UUID v4
UUID version 4 (randomly generated)
UUID (Any Version)
Any RFC 4122 UUID (versions 1-5)
JWT Token
JSON Web Token (header.payload.signature)
Hex String
Any-length hexadecimal string
Base64 String
Standard base64 encoded string
Alphanumeric Username
Username with letters, digits, underscores (3-16 chars)