I have a searchBox for a lightning:dualListBox and written to search according to the searchTerm like below,

handleInit : function(cmp, event) {
    cmp.set('v.options', cmp.get('v.dataImportFields'));
    this.search(cmp, event);

search: function(cmp, event) {
    var searchTerm = cmp.get("v.searchTerm");
    var selectedImport = cmp.get('v.selectedDataImportFields');
    var dataImportFields = cmp.get("v.dataImportFields")
                              item => !searchTerm ||
                              item.value.match(searchTerm) ||

    for(var key of selectedImport) {
        var item = {
            "value":  key,
            "label": key
    cmp.set('v.options', dataImportFields);

In the above search it's case sensitive. Is anyone know how to include case insensitive option for the above implementation. I couldn't figure it an easy way to do it.

  • why dont you just convert everything to lowercaps? – glls Oct 12 '18 at 5:34
  • What do you mean by everything? I can't convert the dataImportFields value to the lowercase(Because it shows the label name of fields). I can change the searchTerm to lower or upper caps but it only search for some particular use cases. – Hariprasath Oct 12 '18 at 5:37

By using a case-insensitive regex, you should be able to get the items you're looking for:

var searchTerm = new RegExp(cmp.get("v.searchTerm"),"i"); // "i" for insensitive match
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.