IIRC, all words starting with A is ‘A.*’

On 5/6/15, 6:30 AM, "Deepak MS" <[email protected]> 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();

Reply via email to