title: UI Gird filter - Invalid regular expression
body: <p>I'm using Angular UI grid to show fields.</p>
  
  <p>I have a textbox that user can filter for all columns in the grid. But when the user put text like "(" or "*" is generated a error: Invalid regular expression</p>
  
  <p>Below is the code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var app = angular.module('app', ['ngTouch', 'ui.grid']);
  
  app.controller('MainCtrl', ['$scope', '$http', function ($scope, $http) {
    var today = new Date();
    $scope.gridOptions = {
      enableFiltering: false,
      onRegisterApi: function(gridApi){
        $scope.gridApi = gridApi;
        $scope.gridApi.grid.registerRowsProcessor( $scope.singleFilter, 200 );
      },
      columnDefs: [
        { field: 'name' },
        { field: 'gender', cellFilter: 'mapGender' },
        { field: 'company' },
        { field: 'email' },
        { field: 'phone' },
        { field: 'age' },
        { field: 'mixedDate' }
      ]
    };
  
    $http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/500_complex.json')
      .success(function(data) {
        $scope.gridOptions.data = data;
        $scope.gridOptions.data[0].age = -5;
  
        data.forEach( function addDates( row, index ){
          row.mixedDate = new Date();
          row.mixedDate.setDate(today.getDate() + ( index % 14 ) );
          row.gender = row.gender==='male' ? '1' : '2';
        });
      });
      
    $scope.filter = function() {
      $scope.gridApi.grid.refresh();
    };
      
    $scope.singleFilter = function( renderableRows ){
      var matcher = new RegExp($scope.filterValue);
      renderableRows.forEach( function( row ) {
        var match = false;
        [ 'name', 'company', 'email' ].forEach(function( field ){
          if ( row.entity[field].match(matcher) ){
            match = true;
          }
        });
        if ( !match ){
          row.visible = false;
        }
      });
      return renderableRows;
    };
  }])
  .filter('mapGender', function() {
    var genderHash = {
      1: 'male',
      2: 'female'
    };
  
    return function(input) {
      if (!input){
        return '';
      } else {
        return genderHash[input];
      }
    };
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.grid {
    width: 500px;
    height: 450px;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!doctype html&gt;
  &lt;html ng-app="app"&gt;
    &lt;head&gt;
      &lt;script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.js"&gt;&lt;/script&gt;
      &lt;script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-touch.js"&gt;&lt;/script&gt;
      &lt;script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-animate.js"&gt;&lt;/script&gt;
      &lt;script src="http://ui-grid.info/docs/grunt-scripts/csv.js"&gt;&lt;/script&gt;
      &lt;script src="http://ui-grid.info/docs/grunt-scripts/pdfmake.js"&gt;&lt;/script&gt;
      &lt;script src="http://ui-grid.info/docs/grunt-scripts/vfs_fonts.js"&gt;&lt;/script&gt;
      &lt;script src="http://ui-grid.info/release/ui-grid.js"&gt;&lt;/script&gt;
      &lt;link rel="stylesheet" href="http://ui-grid.info/release/ui-grid.css" type="text/css"&gt;
      &lt;link rel="stylesheet" href="main.css" type="text/css"&gt;
    &lt;/head&gt;
    &lt;body&gt;
  
  &lt;div ng-controller="MainCtrl"&gt;
    &lt;input ng-model='filterValue'/&gt;&lt;button ng-click='filter()'&gt;Filter&lt;/button&gt;
    &lt;div id="grid1" ui-grid="gridOptions" class="grid"&gt;&lt;/div&gt;
  &lt;/div&gt;
  
  
      &lt;script src="app.js"&gt;&lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thanks.</p>