Space as wildard

11 views
Skip to first unread message

marc....@gmail.com

unread,
May 29, 2016, 5:23:01 PM5/29/16
to select2
Is there a way that I can specify that a space in my search should be treated as a wildcard(*)?


So using the first example at https://select2.github.io/examples.html 'n d' should find "North Dakota" as well as 'n rth' should find "North Dakota" and "North Carolina"

Is there a flag or can I do a simple code change?

Thanks,
Marc

Barry Hunter

unread,
May 29, 2016, 6:07:39 PM5/29/16
to sel...@googlegroups.com
Pretty sure there isnt a flag for this as such, but the 'Customizing how results are matched' example, does show how to change the matching...


Its a bit ugly, but something like would be the most concise... 

if (text.match(new RegExp(term.replace(/ /g,'.*'),'i'))) {


(of course if using a remote data-source, the server side can apply such matching logic) 



--
You received this message because you are subscribed to the Google Groups "select2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to select2+u...@googlegroups.com.
To post to this group, send email to sel...@googlegroups.com.
Visit this group at https://groups.google.com/group/select2.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages