Posts Regex for swedish social security numbers
Post
Cancel

Regex for swedish social security numbers

Simple JS regexp for swedish social security number.

1
2
3
4
5
6
7
/^\d{6,8}[-|(\s)]{0,1}\d{4}$/.test("195505055555") // true

/^\d{6,8}[-|(\s)]{0,1}\d{4}$/.test("19550505-5555") // true

/^\d{6,8}[-|(\s)]{0,1}\d{4}$/.test("550505-5555") // true

/^\d{6,8}[-|(\s)]{0,1}\d{4}$/.test("550505 5555") // true

Source

This post is licensed under CC BY 4.0 by the author.