Skip to main content
NyankoTools

Regex Pattern Library (Japan Edition)

A collection of regular expressions for everyday input validation: Japanese postal codes and phone numbers, katakana and hiragana, plus email, URL, IPv4, dates, UUIDs, and more. Each pattern comes with examples that match and ones that do not, and you can copy it with one click. Paste the copied pattern into the Regex Tester to try it on your own data.

🔒 Runs in your browser · Your data is never sent to a server

Searches names, descriptions, and the patterns themselves. Separate several words with spaces to show only patterns that match all of them.

  • Japanese postal code (hyphen optional)

    Japan

    A 7-digit postal code. Both "100-0001" and "1000001" match. It does not check that the code actually exists.

    ^\d{3}-?\d{4}$

    Flags: none

    ✓ Matches

    • 100-0001
    • 1000001

    ✗ Does not match

    • 100-001
    • 10-00001
    • 100--0001
  • Japanese postal code (hyphen required)

    Japan

    Accepts only the "123-4567" format.

    ^\d{3}-\d{4}$

    Flags: none

    ✓ Matches

    • 100-0001
    • 060-0000

    ✗ Does not match

    • 1000001
    • 100-00011
  • Japanese mobile number

    Japan

    Eleven digits starting with 070, 080, or 090. Hyphens are optional. 050 IP phone numbers are not covered.

    ^0[789]0-?\d{4}-?\d{4}$

    Flags: none

    ✓ Matches

    • 090-1234-5678
    • 08012345678

    ✗ Does not match

    • 060-1234-5678
    • 090-123-45678
    • 0901234567
  • Japanese phone number (with hyphens)

    Japan

    Area code, local code, and subscriber number split by hyphens, such as "03-1234-5678" or "0123-45-6789". Mobile numbers like "090-1234-5678" match too.

    ^0\d{1,4}-\d{1,4}-\d{4}$

    Flags: none

    ✓ Matches

    • 03-1234-5678
    • 045-123-4567
    • 0123-45-6789

    ✗ Does not match

    • 3-1234-5678
    • 03-1234-567
    • 0312345678
  • Japanese phone number (digits only)

    Japan

    A 10- or 11-digit number that starts with 0 and has no hyphens. Hyphenated numbers do not match.

    ^0\d{9,10}$

    Flags: none

    ✓ Matches

    • 0312345678
    • 09012345678

    ✗ Does not match

    • 312345678
    • 031234567
    • 03-1234-5678
  • My Number (12 digits)

    Japan

    Only checks for exactly 12 digits. The check digit is not verified.

    ^\d{12}$

    Flags: none

    ✓ Matches

    • 123456789012

    ✗ Does not match

    • 12345678901
    • 1234-5678-9012
    • 1234567890123
  • Full-width katakana

    Japan

    Strings made only of full-width katakana and the long-vowel mark. Handy for furigana fields. The middle dot and spaces are not allowed.

    ^[ァ-ヶー]+$

    Flags: none

    ✓ Matches

    • ヤマダ
    • ラーメン

    ✗ Does not match

    • やまだ
    • ヤマダ1
    • ヤマダ
    • (empty string)
  • Hiragana

    Japan

    Strings made only of hiragana and the long-vowel mark. Handy for reading (yomigana) fields.

    ^[ぁ-んー]+$

    Flags: none

    ✓ Matches

    • やまだ
    • らーめん

    ✗ Does not match

    • ヤマダ
    • 山田
    • やまだ1
  • Kanji

    Japan

    Strings made only of kanji and the iteration mark 々. It uses a Unicode script property, so the u flag is required.

    ^[\p{Script=Han}々]+$

    Flags: u

    ✓ Matches

    • 山田
    • 佐々木

    ✗ Does not match

    • やまだ
    • 山田1
    • Yamada
  • Half-width katakana

    Characters & whitespace

    Strings made only of half-width katakana, including the voiced sound marks. Use it to detect or reject half-width kana.

    ^[ヲ-゚]+$

    Flags: none

    ✓ Matches

    • ヤマダ
    • アイウ

    ✗ Does not match

    • ヤマダ
    • ヤマダ1
  • Full-width digits

    Characters & whitespace

    Strings made only of full-width digits 0 to 9.

    ^[0-9]+$

    Flags: none

    ✓ Matches

    • 123
    • 0

    ✗ Does not match

    • 123
    • 12
    • 12345a
  • Half-width letters and digits

    Characters & whitespace

    Strings made only of ASCII letters and digits.

    ^[A-Za-z0-9]+$

    Flags: none

    ✓ Matches

    • abc123
    • ABC

    ✗ Does not match

    • abc 123
    • abc_123
    • abc
  • Contains non-ASCII characters

    Characters & whitespace

    Matches when the text has at least one non-ASCII character, such as Japanese, accented letters, or some emoji. The opposite of checking that everything is ASCII.

    [^\x00-\x7F]

    Flags: none

    ✓ Matches

    • abcあ
    • é

    ✗ Does not match

    • abc 123
    • Hello, World!
  • Leading and trailing whitespace

    Characters & whitespace

    Whitespace and line breaks at the start and end of a string. Use it with the g flag in a replace, replacing with nothing, to get the same result as trim.

    ^\s+|\s+$

    Flags: g

    ✓ Matches

    • hello
    • hello
    • hello

    ✗ Does not match

    • hello
    • hello world
  • Blank lines

    Characters & whitespace

    Lines with nothing on them, or only whitespace. With the m flag each line is checked separately.

    ^\s*$

    Flags: m

    ✓ Matches

    • (empty string)
    • a b

    ✗ Does not match

    • abc
    • a b
  • Email address (practical, simplified)

    Web & network

    Checks the common shape of an email address. It does not follow the RFC completely and skips internationalized domains and quoted local parts. Confirm the address by sending a message.

    ^[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}$

    Flags: none

    ✓ Matches

    • a@example.com
    • user.name+tag@sub.example.co.jp

    ✗ Does not match

    • a@b
    • @example.com
    • a@@example.com
    • a b@example.com
  • URL (http / https)

    Web & network

    A URL that starts with http:// or https:// and has no whitespace. Case-insensitive.

    ^https?://[^\s/$.?#][^\s]*$

    Flags: i

    ✓ Matches

    • https://example.com/path?x=1
    • http://localhost:3000
    • HTTP://A.COM

    ✗ Does not match

    • ftp://example.com
    • example.com
    • https://exa mple.com
    • https://
  • Domain name

    Web & network

    A fully qualified domain name whose labels use letters, digits, and hyphens and whose last label has 2 or more letters. Internationalized names are checked in their Punycode (xn--) form.

    ^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$

    Flags: i

    ✓ Matches

    • example.com
    • sub.example.co.jp
    • xn--abc.example

    ✗ Does not match

    • -a.com
    • example
    • a..com
    • a_b.com
  • IPv4 address

    Web & network

    Four numbers from 0 to 255 separated by dots. Values like "256" or zero-padded "01" do not match.

    ^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$

    Flags: none

    ✓ Matches

    • 192.168.0.1
    • 255.255.255.255
    • 0.0.0.0

    ✗ Does not match

    • 256.1.1.1
    • 192.168.0
    • 01.2.3.4
    • 1.2.3.4.5
  • MAC address

    Web & network

    Six pairs of hex digits separated by colons or hyphens. Mixed separators are not rejected.

    ^(?:[0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}$

    Flags: none

    ✓ Matches

    • 00:1A:2B:3C:4D:5E
    • 00-1a-2b-3c-4d-5e

    ✗ Does not match

    • 00:1A:2B:3C:4D
    • 00:1A:2B:3C:4D:5G
    • 001A.2B3C.4D5E
  • Hex color (#RGB / #RRGGBB)

    Web & network

    A "#" followed by 3 or 6 hex digits. The 4- and 8-digit forms with alpha do not match.

    ^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$

    Flags: none

    ✓ Matches

    • #fff
    • #1A2b3C

    ✗ Does not match

    • #ffff
    • fff
    • #ggg
  • X (Twitter) username

    Web & network

    1 to 15 letters, digits, or underscores. The leading "@" is optional.

    ^@?[A-Za-z0-9_]{1,15}$

    Flags: none

    ✓ Matches

    • @nyanko_tools
    • user123

    ✗ Does not match

    • @too_long_name_12345
    • a-b
    • @
  • Date (YYYY-MM-DD)

    Date & time

    Checks that the month is 01-12 and the day is 01-31. Impossible dates such as "2026-02-31" still match, so validate the calendar date separately.

    ^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$

    Flags: none

    ✓ Matches

    • 2026-10-19
    • 2024-02-29

    ✗ Does not match

    • 2026-13-01
    • 2026-10-32
    • 2026/10/19
    • 2026-1-5
  • Date (YYYY/M/D)

    Date & time

    Slash-separated, with optional zero padding on month and day. Impossible dates still match.

    ^\d{4}/(?:0?[1-9]|1[0-2])/(?:0?[1-9]|[12]\d|3[01])$

    Flags: none

    ✓ Matches

    • 2026/1/5
    • 2026/10/19

    ✗ Does not match

    • 2026/00/10
    • 2026/10/32
    • 2026-10-19
  • Time (24-hour HH:MM)

    Date & time

    From 00:00 to 23:59. The hour must be zero-padded.

    ^(?:[01]\d|2[0-3]):[0-5]\d$

    Flags: none

    ✓ Matches

    • 00:00
    • 09:30
    • 23:59

    ✗ Does not match

    • 24:00
    • 12:60
    • 9:30
  • Integer

    Numbers

    A whole number with an optional leading minus sign. A plus sign is not allowed.

    ^-?\d+$

    Flags: none

    ✓ Matches

    • 0
    • -42
    • 007

    ✗ Does not match

    • 1.5
    • +3
    • --1
    • (empty string)
  • Decimal number

    Numbers

    A decimal with a required integer part, so ".5" and "1." do not match. Comma decimal separators are not supported.

    ^-?\d+(?:\.\d+)?$

    Flags: none

    ✓ Matches

    • 3.14
    • -0.5
    • 10

    ✗ Does not match

    • .5
    • 1.
    • 1,5
  • Number with thousands separators

    Numbers

    A positive integer grouped in threes by commas, like "1,234,567".

    ^\d{1,3}(?:,\d{3})*$

    Flags: none

    ✓ Matches

    • 1,234,567
    • 999

    ✗ Does not match

    • 1234,567
    • 12,34
    • 1,2345
  • UUID

    Dev & IDs

    The 8-4-4-4-12 hyphenated format. The version digit is not validated. Case-insensitive.

    ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$

    Flags: i

    ✓ Matches

    • 123e4567-e89b-12d3-a456-426614174000
    • 123E4567-E89B-12D3-A456-426614174000

    ✗ Does not match

    • 123e4567e89b12d3a456426614174000
    • 123e4567-e89b-12d3-a456
  • Semantic version

    Dev & IDs

    Follows the semver.org spec, e.g. "1.2.3" or "1.0.0-beta.1+build.5". A leading "v" is not included.

    ^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$

    Flags: none

    ✓ Matches

    • 1.2.3
    • 1.0.0-beta.1+build.5
    • 0.0.1

    ✗ Does not match

    • 01.2.3
    • 1.2
    • v1.2.3
  • Slug (URL identifier)

    Dev & IDs

    Lowercase letters and digits joined by single hyphens. Leading, trailing, and doubled hyphens are rejected.

    ^[a-z0-9]+(?:-[a-z0-9]+)*$

    Flags: none

    ✓ Matches

    • my-post-1
    • abc

    ✗ Does not match

    • -a
    • a--b
    • A
    • a-
  • Username (3-16 characters)

    Dev & IDs

    Starts with a letter, then letters, digits, or underscores, for 3 to 16 characters in total. Adjust the length and characters to your service.

    ^[A-Za-z][A-Za-z0-9_]{2,15}$

    Flags: none

    ✓ Matches

    • user_01
    • abc

    ✗ Does not match

    • 1user
    • ab
    • a_very_long_user_name
  • Password (8+ characters with upper, lower, and a digit)

    Dev & IDs

    Uses lookaheads (?=...) to require at least one lowercase letter, one uppercase letter, and one digit, with 8 or more characters overall.

    ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$

    Flags: none

    ✓ Matches

    • Passw0rdX
    • aB3dEfGh!

    ✗ Does not match

    • password1
    • PASSWORD1
    • Pass1

How to use

  1. Find a pattern with the search box or the category buttons.
  2. Check the matching and non-matching examples to see whether it fits your case.
  3. Click "Copy" and paste the pattern into your code or validation.
  4. Click "Try in Regex Tester" to open the Regex Tester and try it on your own data.

Notes

  • Patterns are written as JavaScript (ECMAScript) regular expressions. Python, Java, PHP, and others differ in lookaheads, Unicode properties, and how flags are written.
  • Only the pattern itself is copied. If a pattern needs flags (i, m, u, and so on), set the flags shown on its card yourself.
  • The email, date, and password patterns are practical simplifications. A regex cannot confirm that an address exists or that a date is real.
  • Always validate input on the server too. Checks in the browser are a convenience, not a security measure.

Glossary

Anchors (^ and $)

They mark the start and end of the string. Wrapping a pattern in them requires the whole string to match; without them, a partial match is enough for a test to return true.

Lookahead

Checks what follows the current position without consuming characters. It is how a password pattern can require several conditions at once.

Flags

Switches that change how a regex works: i ignores case, m makes ^ and $ work per line, g finds every match, and u enables Unicode handling.

FAQ

Do I need the ^ at the start and $ at the end?

Yes, when you want to check that the entire value has the format. Without them, a match anywhere in the string makes the test return true. For example, dropping ^ and $ from the postal code pattern would also accept "abc1000001xyz". If you want to pull matches out of longer text, remove them instead.

Can I use these patterns in Python, PHP, or Java as they are?

The basics work in most languages, but these patterns are written for JavaScript. Unicode properties such as \p{Script=Han} are spelled differently or unsupported depending on the language, and so is the way flags like i and m are specified. After copying, try the pattern in the language you actually use.

Why is the email pattern not fully RFC-compliant?

A fully compliant pattern would be extremely long and would accept forms that real services never use. This one is a practical simplification that covers the addresses people actually have. A well-formed address still might not exist, so the only reliable check is to send a confirmation email and have the user click the link.

Why does the date pattern accept "2026-02-31"?

A regex only inspects the sequence of characters; it cannot know the calendar. The pattern checks that the month is 01-12 and the day is 01-31. To rule out leap-year and month-length errors, validate the matched string with a Date object or a date library afterward.

How do I allow the middle dot or spaces in the katakana pattern?

Add them to the character class. For names like "マイケル・ジャクソン", use [ァ-ヶー・]; to allow a full-width space too, use [ァ-ヶー・ ]. Paste the edited pattern into the Regex Tester to confirm the characters you want to allow actually pass.

Share this page

↑↓ Select Enter Open Esc Close