flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Deepak MS <megharajdee...@gmail.com>
Subject Filtering ArrayCollection using RegExp
Date Wed, 06 May 2015 13:30:47 GMT
Hi there,
I'm trying to filter an AC using RegExp. The requirement is wild character
search. i.e, if I enter 'A*' (asterisk), then I need to display all items
that start with 'A'.

I haven't used RegExps much before. I feel I'm missing something here.
Coudn't get much on net either. Can you kindly help me on this?

This is the code:

if(tiSearch.text.indexOf('*') > -1)
                    {
                        var searchText:String = tiSearch.text.slice(0,
tiSearch.text.length - 1);//trying to remove * and use only the characters
here
                            dataLoader.atcDetailsList.filterFunction =
function wildCardfilterATCs(item:Object):Boolean
                            {
                                var regExp:RegExp = new RegExp(searchText,
"w*");//not working
                                return regExp.test( item['AtcDesc'] );
                            }
                    }else
                    {
                        dataLoader.atcDetailsList.filterFunction = function
filterATCs(item:Object):Boolean
                        {
                            searchText = tiSearch.text
                            var regExp:RegExp = new RegExp( searchText, "i"
); //this works fine, without asterisk. Lists all items that has search
character anywhere in the item.
                            return regExp.test( item['AtcDesc'] );

                        }
                    }

dataLoader.atcDetailsList.refresh();

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message