Regex for US EIN (Employer ID)
Regex Pattern
^\d{2}-\d{7}$US Employer Identification Number (XX-XXXXXXX)
Quick Answer
The regex pattern for us ein (employer id) is `^\d{2}-\d{7}$`. US Employer Identification Number (XX-XXXXXXX). This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.
Test Examples
| Input | Result |
|---|---|
| 12-3456789 | ✓ Matches |
| 00-1234567 | ✓ Matches |
| 99-9999999 | ✓ Matches |
| 123456789 | ✗ No match |
| 12-345678 | ✗ No match |
| 12-34567890 | ✗ No match |
Code Examples
javascript
const regex = /^\d{2}-\d{7}$/;
const isValid = regex.test(value);python
import re
pattern = r'^\d{2}-\d{7}$'
if re.match(pattern, value):
print("valid")ruby
pattern = /^\d{2}-\d{7}$/
if value =~ pattern
puts "valid"
endphp
if (preg_match('/^\d{2}-\d{7}$/', $value)) {
echo "valid";
}java
String pattern = "^\\d{2}-\\d{7}$";
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)