Regular Expressions 101

Community Patterns

Non-repetitive set permutations

1

Regular Expression
PCRE2 (PHP >=7.3)

/
(?<!\S)(?P<set> (?:(?P<a>A) | (?P<b>B) | (?P<c>C)) (?: (?(a) (?!A)) (?(b) (?!B)) (?(c) (?!C)) (?&set) )? )\s
/
gmx

Description

Matches any non-repetitive permutations of characters in a set, separated by whitespaces. For the set of characters ABC: Matches: A, BAC, CA... Doesn't match: BB, ABA, CBD...

Submitted by nuru - 13 days ago (Last modified 12 days ago)