title: Regular expression to match first few characters repeated twice in string
body: <p>I am facing an issue to find all strings which have <strong>first few (>=2) characters</strong> repeated <strong>twice</strong> in a string in R language.<br>
  E.g  </p>
  
  <p><em>The strings should select out</em><br>
  (1) <strong>all</strong>ochir<strong>all</strong>y ------> first 3 characters 'all' repeated twice in string<br>
  (2) <strong>froufrou</strong> ------> first 4 characters 'frou' repeated twice in string<br>
  (3) <strong>under</strong>gro<strong>under</strong> ------> first 5 characters 'under' repeated twice in string  </p>
  
  <p><em>The strings should <strong>NOT</strong> select out</em><br>
  (1) gummage ------> even first character 'g' repeated twice, but only 1 character, not match condition as >=2 first characters<br>
  (2) hypergoddess ------> no first few characters repeated twice<br>
  (3) kgashga ------> even 'ga' repeated twice, but not including the first character 'k', not match condition which require including the first character  </p>
  
  <p>Heard about <code>backreference</code> (e.g \b or \w) might be helpful, but still not able to figure out, could you help to figure out ?  </p>
  
  <p>Note: I see there is a function as <code>xmatch &lt;- str_extract_all(x, regex) == x</code> as the method to use, the <code>str_extract_all</code> from <code>library(stringr)</code>  </p>
  
  <pre><code>x &lt;- c("allochirally", "froufrou", "undergrounder", "gummage", "hypergoddess", "kgashga")
  regex &lt;- "as described details here"
  function(x, regex) {
    xmatch &lt;- str_extract_all(x, regex) == x
    matched_x &lt;- x[xmatch]
  }
  </code></pre>
  
  <p>If <strong>very concise</strong> would prefer!! Thanks </p>