title: Angular 2 pipe replace with source value
body: <p>I wrote the following pipe to highlight matching:</p>
  
  <pre><code>import {PipeTransform, Pipe} from '@angular/core';
  
  @Pipe({ name: 'highlight' })
  export class HighlightPipe implements PipeTransform {
    transform(values: any, filter: string): any[] {
      let highlightedValues = [];
  
      values.forEach(function(entry) {
        let result = filter ? HighlightPipe.doHighlight(entry, filter) : entry;
        filter ? highlightedValues.push(result) : highlightedValues.push(entry);
      });
  
      return highlightedValues;
    }
  
    private static doHighlight(entry:any, filter:string):any {
      return {
        title: entry.title.replace(new RegExp(filter, 'gi'), `&lt;span class="highlight"&gt;${filter}&lt;/span&gt;`),
        content: entry.content.replace(new RegExp(filter, 'gi'), `&lt;span class="highlight"&gt;${filter}&lt;/span&gt;`)
      };
    }
  }
  </code></pre>
  
  <p>The pipe works fine and hihlights matches. The problem occurs, when I search for an upper case string. The upper case string replaces the source text <strong>what is not wanted behaviour</strong>.</p>
  
  <p>For example: I search for <code>Array</code> string and the source string (<code>array</code>) gets replaced with <code>Array</code> string. How can I make pipe return <code>array</code> and not <code>Array</code>?</p>
  
  <p>P.S. <code>highlightedValues</code> is there, because the pipe takes output from another pipe.</p>