Regular Expressions 101

Community Patterns

1...34567...886

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 - 2 months ago (Last modified 2 months ago)