flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: Filtering ArrayCollection using RegExp
Date Wed, 06 May 2015 19:23:01 GMT
IIRC, all words starting with A is ‘A.*’


On 5/6/15, 6:30 AM, "Deepak MS" <megharajdeepak@gmail.com> wrote:

>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
View raw message