title: Regular expression for "at most"
body: <p>I am currently thinking about how best to express "At most two" as a regular expression. </p>
  
  <p><code>str_detect("xxx", "x{0,2}")</code> gives <code>TRUE</code> and I understand why. For example because of the first two <code>x</code>. I want a regular expression that gives <code>FALSE</code>. <code>str_detect("xxx", "x{0,2}[^x]")</code> achieves this, that's fine. <code>str_detect("xxx", "x{0,2}(?!x)")</code> leads to <code>TRUE</code>, I am quite surprised because of that. Why is this the case?</p>
  
  <p>Can you think of another regular expressions that are smarter than <code>x{0,2}[^x]</code>? I think it's OK but I'm wondering if there is no shorter solution.</p>