Simple code golf challenge: Character patterns! In this challenge, you receive a string as input containing a string of X's, Y's and Z's eg. "XYZZ". X, Y and Z represent a particular character. This pattern is then compared with a second string input. If the pattern exists as a substring in the second input, return True, otherwise, return False. Once a pattern is found in the word, the program stops searching and returns True.

Examples

Pattern: "XXYY"

succeed ---&gt; True (pattern found: ccee)
success ---&gt; False (pattern not matched)
balloon ---&gt; True (pattern found: lloo)


Pattern: "XYXYZ"

bananas ---&gt; True (pattern found: nanas)
banana  ---&gt; False (pattern not found)



Note: This is not the actual input. This is an example of how the  program should work. Your program should output True or False, or other Truthy/Falsy values.


Other important/useful information


The pattern does not need to contain an X, Y and a Z, it could contain X's and Y's or even (although somewhat pointless) just X's.
The pattern cannot be empty, but this will not be used as a test case.
The search string will not be empty, and will be lowercase.
The alphabetic order of X, Y and Z in the pattern does not matter.
X, Y and Z must be unique characters.
You may use any library you wish.
The score is determined by the code size, in bytes. Lowest score wins.


Good luck!
Perl 5, 85 bytes

Saved 40 bytes thanks to Peter Taylor's suggestion! (see my older version bellow to see the differences)

83 bytes of code + -pl flag.



s/./$h{$&amp;}?"\\$h{$&amp;}":($h{$&amp;}=$.,join("",map"(?!\\$_)",1..$.++)."(.)")/ge;$_=&lt;&gt;=~$_


Try it online!

XYXYZ is transformed into ((?!\1).)((?!\1)(?!\2).)\1\2((?!\1)(?!\2)(?!\3).) (yup, some of the tests can't be true, but it's shorter that way), and the second input is then checked against that regex. (see the explanations of my older version to get more intuition of how it works)



My older version:
Thanks to Arnauld for pointing out a mistake I made in my first version.
113 bytes of code + -pl flags, and -Mre=eval.

s/./$h{$&amp;}?"\\$h{$&amp;}":($h{$&amp;}=++$i,"(.)")/ge;$_.='(?{++$c;$\=1if!grep$v{$c}{${$_}}++,1..'.(keys%h).'})^';&lt;&gt;=~$_}{


Try it online!

On the example XYXYZ: the first regex will convert the pattern to (.)(.)\1\2(.), and add at the end a test to check if $1, $2 and $3 are different: if so, $\ is set to one. Then, the second input is testes against this regex, and $\ is implicitely printed at the end.
The regex generated for XYXYZ is (.)(.)\1\2(.)(?{++$c;$\=1if!grep{$v{$c}{${$_}}++}1..3})^.
(I'll to add a bit more details to the explanations when I have a moment)