using captured groups in str_replace / stri_replace - stringi vs stringr
<p>Most <code>stringr</code> functions are just wrappers around corresponding <code>stringi</code> functions. <code>str_replace_all</code> is one of those. Yet my code does not work with <code>stri_replace_all</code>, the corresponding <code>stringi</code> function.</p>

<p>I am writing a quick regex to convert (a subset of) camel case to spaced words.</p>

<p>I am quite puzzled as to why this works:</p>

<pre><code>str &lt;- "thisIsCamelCase aintIt"
stringr::str_replace_all(str, 
                         pattern="(?&lt;=[a-z])([A-Z])", 
                         replacement=" \\1")
# "this Is Camel Case ain't It"
</code></pre>

<p>And this does not:</p>

<pre><code>stri_replace_all(str, 
                 regex="(?&lt;=[a-z])([A-Z])", 
                 replacement=" \\1")
# "this 1s 1amel 1ase ain't 1t"
</code></pre>