DD
DevDash

Regex for German Phone Number

Regex Pattern

^(?:\+49|0)[1-9]\d{1,14}$

German phone number with optional +49 country code

Quick Answer

The regex pattern for german phone number is `^(?:\+49|0)[1-9]\d{1,14}$`. German phone number with optional +49 country code. This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.

Test Examples

InputResult
+4915112345678✓ Matches
015112345678✓ Matches
+491701234567✓ Matches
+49012345✗ No match
12345✗ No match
+44712345678✗ No match

Code Examples

javascript

const regex = /^(?:\+49|0)[1-9]\d{1,14}$/;
const isValid = regex.test(value);

python

import re
pattern = r'^(?:\+49|0)[1-9]\d{1,14}$'
if re.match(pattern, value):
    print("valid")

ruby

pattern = /^(?:\+49|0)[1-9]\d{1,14}$/
if value =~ pattern
  puts "valid"
end

php

if (preg_match('/^(?:\+49|0)[1-9]\d{1,14}$/', $value)) {
    echo "valid";
}

java

String pattern = "^(?:\\+49|0)[1-9]\\d{1,14}$";
boolean isValid = value.matches(pattern);

Frequently Asked Questions

Related Regex Patterns

Want API access + no ads? Pro coming soon.