title: Regular expression (regex): each character can appear at most as many as given
body: <p>So far I have this regex <code>^(?!.*?(a|c|e|g|i).*?\1)[acegi]+$</code> which match any word as combination of the characters "acegi", and these characters can occur only once.</p>
  
  <p>Now I'm trying to match any word which will consist of given characters and these characters can repeat as many times as given.</p>
  
  <p><strong>Example for set of given characters "acegii"</strong></p>
  
  <p>Valid matches: "acegii" "ace" "a" "i" "ai" "gii" "ici" "iic" "aicige" etc.</p>
  
  <p>Invalid matches: "acegiii" "iacegii" "iii" "aa" "cc" etc.</p>
  
  <p>Thanks for any help!</p>
  
  <p><em>Note: the characters set in the regex should be easily replaceable if possible.</em></p>
  
  <p><em>Prefered regexs: posix, ruby</em></p>