Regular Expressions 101

Community Patterns

Match the distinct letters used in a string

1

Regular Expression
PCRE2 (PHP >=7.3)

/
([a-zA-Z])(?!.*\1)
/
g

Description

This finds a letter and omits all other instances of that letter, leaving you only the distinct letters used in the string.

Submitted by Ember B - 7 months ago