Regex for French Postal Code
Regex Pattern
^\d{5}$French postal code — exactly 5 digits
Quick Answer
The regex pattern for french postal code is `^\d{5}$`. French postal code — exactly 5 digits. This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.
Test Examples
| Input | Result |
|---|---|
| 75001 | ✓ Matches |
| 13001 | ✓ Matches |
| 69001 | ✓ Matches |
| 7500 | ✗ No match |
| 750010 | ✗ No match |
| ABCDE | ✗ No match |
Code Examples
javascript
const regex = /^\d{5}$/;
const isValid = regex.test(value);python
import re
pattern = r'^\d{5}$'
if re.match(pattern, value):
print("valid")ruby
pattern = /^\d{5}$/
if value =~ pattern
puts "valid"
endphp
if (preg_match('/^\d{5}$/', $value)) {
echo "valid";
}java
String pattern = "^\\d{5}$";
boolean isValid = value.matches(pattern);