title: Removing a trailing Space from Regex Matched group
body: <p>I'm using regular expression lib icucore via RegKit on the iPhone to
  replace a pattern in a large string.</p>
  
  <p>The Pattern i'm looking for looks some thing like this</p>
  
  <pre><code>| hello world (P1)|
  </code></pre>
  
  <p>I'm matching this pattern with the following regular expression</p>
  
  <pre><code>\|((\w*|.| )+)\((\w\d+)\)\|
  </code></pre>
  
  <p>This transforms the input string into 3 groups when a match is found, of which group 1(string) and group 3(string in parentheses) are of interest to me.</p>
  
  <p>I'm converting these formated strings into html links so the above would be transformed into </p>
  
  <pre><code>&lt;a href="P1"&gt;Hello world &lt;/a&gt;
  </code></pre>
  
  <p>My problem is the trailing space in the third group. Which when the link is highlighted and underlined, results with the line extending beyond the printed characters.</p>
  
  <p>While i know i could extract all the matches and process them manually, using the search and replace feature of the icu lib is a much cleaner solution, and i would rather not do that as a result.</p>
  
  <p>Many thanks as always</p>