954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Extjs store filtering - include metachars

I have a data store having a Note field (a textarea) and want to display all Notes satisfying a user input (even metacharacters).

I've written the following function to handle this:
[CODE]
function notefilter() {
var newfilter = Ext.getCmp('searchnote');
var searchStr = newfilter.getValue();
searchStr = searchStr.replace('?', '\\?').replace('*', '\\*').replace('+', '\\+').replace('{', '\\{').replace('}', '\\}').replace('[', '\\[').replace(']', '\\]').replace('(', '\\(').replace(')', '\\)').replace('|', '\\|').replace('$', '\\$').replace('^', '\\^');

var re = new RegExp(".*" + searchStr + ".*", "ig");
Ext.getCmp('notesgrid').store.filter('Note', re);
}
[CODE]
However the filter fails to search for metacharacters even after escaping them, but it works are all other alphanumeric input.

Am I missing something ?

Thanks in advance !

deepak.marur
Newbie Poster
11 posts since May 2009
Reputation Points: 10
Solved Threads: 1
 

Have you looked at the JS built-ins 'escape()' and 'unescape()'?

MartinRinehart
Junior Poster in Training
97 posts since Jun 2010
Reputation Points: 11
Solved Threads: 10
 

Thanks the hint. You saved my day. escape() did the work for me.

deepak.marur
Newbie Poster
11 posts since May 2009
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: