var regExp:RegExp = new RegExp(searchText, searchText+".*")
That doesn’t look right. I would think it would be: new RegExp(searchText+”.*”, “”) I think you can also try: new RegExp(“^”+searchText+”.*”, “”) I think there may be some internet sites where you can practice regex. -Alex On 5/6/15, 8:50 PM, "Deepak MS" <[email protected]> wrote: >'A' here would be dynamic. It actually can be anything which user enters >in >the search text input. Based on your suggestion, I tried this code, still >not getting it right: >if(tiSearch.text.indexOf('*') > -1) > { > var searchText:String = tiSearch.text.slice(0, >tiSearch.text.length - 1); > dataLoader.atcDetailsList.filterFunction = >function wildCardfilterATCs(item:Object):Boolean > { > var regExp:RegExp = new RegExp(searchText, >searchText+".*"); //searchText = 'A' > return regExp.test( item['AtcDesc'] ); > } > } > >If I enter 'A*' it shows me all the items which has 'A' in it irrespective >of it's location within the item. > >On Thu, May 7, 2015 at 12:53 AM, Alex Harui <[email protected]> wrote: > >> 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(); >> >>
