Regular Expressions

Introduction

It is often useful to know if a text string (like "filled.count.soap") looks like a 3 word address, without having to ask the API. To make life easier for developers, we provide the Regexes below for different programming languages. You can use them to identify strings that could be 3 word addresses.

There are two types of regular expression for detecting 3 word addresses. One for complete 3 word addresses, such as 'index.home.raft', and one for incomplete addresses, such as 'index.home.r'. The second type is typically used during autocomplete, whilst you type. Generally, the second type is identical to the first, aside from the number of required characters for the third word lowered to 1 instead of 2.

Sample Regular Expressions

Regular expressions are provided for PHP (PCRE), JavaScript and Python. The three samples provided here should be used in an autocomplete context where you want to validate on the first character of the third word. If you want to validate complete 3 word addresses you should up the required number of characters required for the third word from 1 to 2.

PHP (PCRE)

^(?:\p{L}\p{M}*){2,}[・.](?:\p{L}\p{M}*){2,}[・.](?:\p{L}\p{M}*){1,}$

JavaScript

/^[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]{2,}[・.][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]{2,}[・.][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]{1,}$/i

Python

r"^[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/\";:£§º©®\s]{2,}[・.][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/\";:£§º©®\s]{2,}[・.][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/\";:£§º©®\s]{1,}$"