title: Regex to match all permutations of {1,2,3,4} without repetition
body: <p>I am implementing the following problem in ruby.</p>
  
  <p>Here's the pattern that I want :</p>
  
  <p>1234, 1324, 1432, 1423, 2341 and so on</p>
  
  <p>i.e. the digits in the four digit number should be between [1-4] and should also be non-repetitive.</p>
  
  <p>to make you understand in a simple manner I take a two digit pattern
  and the solution should be :
  12, 21</p>
  
  <p>i.e. the digits should be either 1 or 2 and should be non-repetitive.</p>
  
  <p>To make sure that they are non-repetitive I want to use $1 for the condition for my second digit but its not working. </p>
  
  <p>Please help me out and thanks in advance.</p>