-1

I have this piece of code :

 getText: function(record) {
     var inSearch = Ext.getCmp("incidentsFilters__search").value;
     var replaceWith = '<span class="search-results-colored-text" >'+inSearch+'</span>';
     var record = record.text.join(', '); 

     record = record.replace(new RegExp(inSearch,"g"), replaceWith);

     return record;
}

When I search " .e " , it returns something like this :
enter image description here
It should return something like this (it works ok when I search ".exe")
enter image description here

I think I should add something to my RegExp, can't figure out what.

flori
  • 428
  • 1
  • 6
  • 22

1 Answers1

0

You will need to escape the . as it matches any char. Here is a simplified version.

var myFile = 'myFile.exe'

myFile.match(/.e/g) // matches [ 'le', '.e', 'xe' ]
myFile.match(/\.e/g) // matches [ '.e' ]

You should add .replace('.', '\.') to the search value.

Eruant
  • 1,816
  • 2
  • 14
  • 22