Regular Expressions 101

Community Patterns

INSEE code for french municipalities

0

Regular Expression
ECMAScript (JavaScript)

/
^(0[1-9]|[1-9][ABab\d])\d{3}$
/
gm

Description

This is a regex that allows you to match INSEE codes for a french municipality.

It is different from a french postal code, because it can have "A" or "B" in its second character, used in codes for cities located in Corse.

Example: 2A004 for Ajaccio.

Submitted by thomasdom - 2 years ago (Last modified 2 years ago)