Last updated: 3 min ago
PatternsphoneCell Phone Check Csharp Example

Cell Phone Check Csharp Example

cell phone check csharp example for production applications

Verified Pattern
beginner
csharp
100%(3714 tests)
medium
14474

Regex Pattern

/^\+?1?[-\.\s]?\(?[0-9]{3}\)?[-\.\s]?[0-9]{3}[-\.\s]?[0-9]{4}$/

How it Works

This regex pattern validates cell phone check csharp example. Commonly used by developers for input validation and form checking.

Test This Pattern

Regex Pattern Tester

Pattern is valid/^\+?1?[-\.\s]?\(?[0-9]{3}\)?[-\.\s]?[0-9]{3}[-\.\s]?[0-9]{4}$/g

Test Single Input

Test Multiple Inputs

Run Predefined Test Cases

Should Match (4)

555-123-4567
(555) 123-4567
+1-555-123-4567
555.123.4567

Should Not Match (6)

123
not-phone
555
123-45-6789
not-a-phone
+1-555-123-456

Test Cases

Should Match (4)

555-123-4567
(555) 123-4567
+1-555-123-4567
555.123.4567

Should Not Match (6)

123
not-phone
555
123-45-6789
not-a-phone
+1-555-123-456

Code Examples

// cell phone check csharp example - JavaScript
const regex = /^\+?1?[-\.\s]?\(?[0-9]{3}\)?[-\.\s]?[0-9]{3}[-\.\s]?[0-9]{4}$/;

function validate(input) {
  if (!input || typeof input !== 'string') return false;
  return regex.test(input.trim());
}

// Usage examples
console.log(validate('555-123-4567')); // true
console.log(validate('123')); // false
# cell phone check csharp example - Python
import re

pattern = r"^\+?1?[-\.\s]?\(?[0-9]{3}\)?[-\.\s]?[0-9]{3}[-\.\s]?[0-9]{4}$"
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('555-123-4567'))  # True
print(validate('123'))  # False
<?php
// cell phone check csharp example - PHP
function validate($input) {
    if (!is_string($input) || empty(trim($input))) {
        return false;
    }
    
    $pattern = '/^\+?1?[-\.\s]?\(?[0-9]{3}\)?[-\.\s]?[0-9]{3}[-\.\s]?[0-9]{4}$/';
    return preg_match($pattern, trim($input)) === 1;
}

// Usage examples
var_dump(validate('555-123-4567')); // bool(true)
var_dump(validate('123')); // bool(false)
?>