Does anyone have a regex for Irish postcodes?

This would be very useful. Thanks. :slight_smile:

Quoting from Postal addresses in the Republic of Ireland - Wikipedia

Each code consists of seven letters and/or digits, with a space after the third character. The first character is always a letter and the second is always a digit. The third character may be either a digit or the letter W, but not any other letter. The remaining four characters may either be letters or digits.

You didn’t specify a regex format, but it would commonly be understood as “[A-Z][0-9][0-9|W] [0-9|A-Z]{4}”

1 Like

I’m using LibreOffice Calc, and this is perfect, thank you.

Please mark my answer as the solution, so others know that it has been solved. Thanks!

I haven’t got enough kudos on the Irish forum. At least - I think that’s why I can’t mark a solution here, but I can elsewhere.

1 Like
2 Likes

Using PCRE Perl compatible regex, the ‘|’ in the square brackets would be allowed as well. Being in those square brackets, the ‘|’ is not seen as an OR but rather as is.

Yeah, it’s sort of a “human readable” version that’s in no specific format.

Using the PCRE format, which is wide-spread, the regex could be written more precisely like that:
[A-Z][0-9][0-9W] [0-9A-Z]{4}

This regex also works in Libreoffice Calc, which uses ICU Regular Expressions as per the REGEX documentation.

1 Like