diff --git a/coffee/lib/abstract-chosen.coffee b/coffee/lib/abstract-chosen.coffee index bf0e785a1ae..b5e86027d42 100644 --- a/coffee/lib/abstract-chosen.coffee +++ b/coffee/lib/abstract-chosen.coffee @@ -36,6 +36,7 @@ class AbstractChosen @max_shown_results = @options.max_shown_results || Number.POSITIVE_INFINITY @case_sensitive_search = @options.case_sensitive_search || false @hide_results_on_select = if @options.hide_results_on_select? then @options.hide_results_on_select else true + @escape_special_characters = true set_default_text: -> if @form_field.getAttribute("data-placeholder") @@ -165,7 +166,10 @@ class AbstractChosen results = 0 searchText = this.get_search_text() - escapedSearchText = searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") + if @escape_special_characters + escapedSearchText = searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") + else + escapedSearchText = searchText regex = this.get_search_regex(escapedSearchText) highlightRegex = this.get_highlight_regex(escapedSearchText) diff --git a/public/options.html b/public/options.html index c64d5a6747f..14f49ad08a6 100644 --- a/public/options.html +++ b/public/options.html @@ -137,6 +137,13 @@

Example:

By default Chosen's results are hidden after a option is selected. Setting this option to false will keep the results open after selection. This only applies to multiple selects.

+ + escape_special_characters + true + +

By default Chosen's search will escape any special characters. Setting this option to false will allow the user to entire a javascript regex eg: foo.*bar will now match foobazbar

+ + rtl false