title: How to replace matches in a string and index each match
body: <p>A particular string can contain multiple instances of a pattern that I'm trying to match. For example, if my pattern is <code>&lt;N(.+?)N&gt;</code> and my string is <code>"My name is &lt;N Timon N&gt; and his name is &lt;N Pumba N&gt;"</code>, then there are two matches. I want to replace each match with a replacement that includes an index for which match is being replaced.</p>
  
  <p>So in my string <code>"My name is &lt;N Timon N&gt; and his name is &lt;N Pumba N&gt;"</code>,
  I want to change the string to read <code>"My name is [Name #1] and his name is [Name #2]"</code>.</p>
  
  <p>How do I accomplish this, preferably with a single function? And preferably using functions from <code>stringr</code> or <code>stringi</code>?</p>