Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
^(?i)(((ldap|ldap):\/\/){0,1})((?i)(ou|cn)=(([a-zA-Z0-9]|[-]|[_])){1,63},)+((?i)(dc=)(([a-zA-Z0-9]|[-]|[_])){1,63},){1,2}(?i)(dc=)(([a-zA-Z0-9]){2,63})$
/
gm

Description

Validates an LDAP DN like one of the following CN=users,DC=example,DC=com OU=mailgroups,OU=People,OU=organisation,DC=example,DC=at LDAP://OU=mailgroups,OU=People,OU=organisation,DC=example,DC=at

Submitted by Daywalker - 9 years ago