stefanocudini / bootstrap-list-filter

Search widget to filter Bootstrap lists
https://opengeo.tech/bootstrap-list-filter/
MIT License
99 stars 31 forks source link

Not filtering on special characters #1

Closed alexrogers closed 10 years ago

alexrogers commented 10 years ago

Trying to filter using '$' but this issue applies to any special character in a javascript regexp. Because the character is not escaped the results are incomplete.

I added some code to escape the character when required after line 43. Not thoroughly tested yet and it's possibly what you were trying to do anyway.

val = val.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");

code taken from http://stackoverflow.com/a/9310752/184129

stefanocudini commented 10 years ago

hi @uberweb!

I'm found another way:

val = val.replace(new RegExp("[({[^.$*+?\\\]})]","g"),'');

this strip completely any regexp special char!

stefanocudini commented 10 years ago

I'm thinking about question... $ is better remove.. on server side using nosql database may be cause problems...

alexrogers commented 10 years ago

@stefanocudini that worked for me on a static list. I'm not sure of the repercussions of using it in ajax request.