Regular Expressions 101

Community Patterns

Community Library Entry

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 - 3 years ago (Last modified 3 years ago)