Email Address Format Php Example
email address format php example for production applications
Pattern Views
16,725
↗ 12.5%Last 30 days
Community Rating
⭐
94%
475 likes
Regular Expression
/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
Explanation
This regex pattern validates email address format php example. Commonly used by developers for input validation and form checking.
Code Examples
JavaScript Example
javascript
// email address format php example - JavaScript
const regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
function validate(input) {
if (!input || typeof input !== 'string') return false;
return regex.test(input.trim());
}
// Usage examples
console.log(validate('user@example.com')); // true
console.log(validate('invalid@')); // falsePython Example
python
# email address format php example - Python
import re
pattern = r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
regex = re.compile(pattern)
def validate(input_str):
if not input_str or not isinstance(input_str, str):
return False
return bool(regex.match(input_str.strip()))
# Usage examples
print(validate('user@example.com')) # True
print(validate('invalid@')) # FalsePHP Example
php
<?php
// email address format php example - PHP
function validate($input) {
if (!is_string($input) || empty(trim($input))) {
return false;
}
$pattern = '/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/';
return preg_match($pattern, trim($input)) === 1;
}
// Usage examples
var_dump(validate('user@example.com')); // bool(true)
var_dump(validate('invalid@')); // bool(false)
?>Test Cases
✓ Should Match
user@example.com
test@domain.org
✗ Should NOT Match
invalid@
not-email
Performance
Speed
medium
Memory
low