title: A regular expression that replaces a group with hard coded text
body: <p>First of all, I'm not sure if this is something you can even do in regular expressions. If you can, I have no idea on how to search for how to do it.</p>
  
  <p>Let's say I have text:</p>
  
  <pre><code>Click &lt;a href="/follow"&gt;this link&lt;/a&gt; for more information.
  </code></pre>
  
  <p>And a regular expression:</p>
  
  <pre><code>&lt;a[^&gt;]*&gt;([^&lt;]*)&lt;/a&gt;
  </code></pre>
  
  <p>The application of the regular expression would yield this for group 1:</p>
  
  <pre><code>this link
  </code></pre>
  
  <p>Let's say I wanted to write the regular expression to instead return hard coded text for group 1</p>
  
  <pre><code>&lt;a[^&gt;]*&gt;(${{replacement text}}[^&lt;]*)&lt;/a&gt;
  </code></pre>
  
  <p>(<em>this is made up syntax by the way</em>)</p>
  
  <p>So that the application of the regular expression to the text would yield this for group 1:</p>
  
  <pre><code>replacement text
  </code></pre>
  
  <p>Is this possible?</p>
  
  <p>Here's another example just to solidify my objective:</p>
  
  <p>Examples of text:</p>
  
  <pre><code>serverNode1/appPortal
  serverNode1/appPortal2
  serverNode1/appPortal3
  </code></pre>
  
  <p>My regular expression</p>
  
  <pre><code>appPortal((?:?{{"1"}}\b)|(?:\d))
  </code></pre>
  
  <p>(<em>using the same made up syntax</em>)</p>
  
  <p>The expected output for the first character group should be</p>
  
  <pre><code>1
  2
  3
  </code></pre>
  
  <p>(The point of the expression is to match the word break and replace it with "1" or otherwise use the digit character class to match a digit. The sub-groups are made optional with the <code>?:</code> so the outside group is still group 1).</p>
  
  <p>What is the point of this you may ask? I am using <a href="http://www.splunk.com" rel="nofollow" title="Splunk">Splunk</a> to do field extractions, and I'd like for the field to be extracted as 1, 2, or 3, like in my above example, and I can only rely on the regular expression groups to give me the fields (as in, I don't have anywhere to put code to say if group 1 == "" then change to "1").</p>