Regular Expressions 101

Community Patterns

Community Library Entry

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 - a year ago