title: invalid group reference when using re.sub()
body: <p>I'm having troubles with re.sub. I understand from other answers that this is due to the fact I'm referencing to a capturing group that I don't have.</p>
  
  <p>My question is: how do I adjust my code to have a valid group?</p>
  
  <pre><code>s = "hello a world today b is sunny c day"
  markers = "a b c".split()
  pattern = r'\b' + ' (?:\w+ )?(?:\w+ )?'.join(markers) + r'\b'
  text = re.sub(pattern, r'&lt;b&gt;\1&lt;/b&gt;', s)   # this gives error
  </code></pre>
  
  <p>I want to have this : <code>"hello &lt;b&gt;a  world today b is sunny c&lt;/b&gt; day"</code></p>