javascript - Angularjs ui utils highlight filter breaks application on search -



javascript - Angularjs ui utils highlight filter breaks application on search -

i using angular ui-utils highlight filter , have next code:

<span data-ng-bind-html="organization.level1name | highlight:vm.search"></span>

when search using special character [ or (, angular exception , application breaks.

syntaxerror: invalid regular expression: /(/: unterminated grouping @ new regexp (native) @ v. (http://localhost:50463/eia/source/dist/vendor.min.js:72:1157) @ (http://localhost:50463/eia/source/dist/vendor.min.js:38:92754) @ cr.| (http://localhost:50463/eia/source/dist/vendor.min.js:38:86832) @ h.constant (http://localhost:50463/eia/source/dist/vendor.min.js:38:92126) @ object.e (http://localhost:50463/eia/source/dist/vendor.min.js:38:101832) @ v.$digest (http://localhost:50463/eia/source/dist/vendor.min.js:38:57280) @ v.$apply (http://localhost:50463/eia/source/dist/vendor.min.js:38:58986) @ http://localhost:50463/eia/source/dist/client.js:1007:31 @ http://localhost:50463/eia/source/dist/vendor.min.js:38:64888 undefined

i tried using ng-sanitize library still same error.

please, how resolve that?

you should escape regexp input since ( special character regular expressions:

function escaperegexp(str) { homecoming str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); }

then, utilize it:

new regexp(escaperegexp(search), 'gi')

javascript regex angularjs angular-ui angularjs-ui-utils

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -