title: Restrict total number of certain characters in PCRE to N
body: <p>Is there a way to write such a regular expression that would match a string in which a certain character occurs N times, or between M and N times? The character can be spread all over the string. That makes it difficult to use regex.</p>
  
  <p>I need to use PCRE C/C++ library. At first glance it does not look like the right job for regex but is trivial to do with string methods but for various reasons it is desirable for me to find a regex solution to this.</p>
  
  <p>My first guess is that I need to use callout feature of PCRE to call a function that would compute the number of occurances of character C in the captured sequence and accept or reject such a match. Not sure yet if callout feature can be used this way.</p>