You can use String.indexOf() instead of String.search() if you don't want any sort of pattern matching at all. Or, you could take the string the user enters and run that through an escaping function before using it with String.search(). Something like:
if(item.Phone.search( myEscapeFunc(searchBar.text) ) >= 0) --- In [email protected], "camlinaeizerous" <[EMAIL PROTECTED]> wrote: > > I had not thought of that, and your right the .search() is detecting > it as a regex expression. Being I can't expect the end user to > understand to type \(###\)###-#### to filter phone numbers is there a > simple way to make it ignore the characters and not take it as a regex? > > > --- In [email protected], "Doug Lowder" <douglowder@> wrote: > > > > Seems like the (, ), and * are being interpreted as regexp > > quantifiers. You can escape them if you want them treated as > > literals. > > > > http://livedocs.macromedia.com/flex/2/docs/00001904.html#118959 > > > > --- In [email protected], "camlinaeizerous" <camlinae@> > > wrote: > > > > > > I have a list of phone numbers in either a (###)###-#### of > > > ###-###-#### type format. There is also a text box that on change > > > filters array collection that populates the list. The code breaks > > down to. > > > > > > private function phoneFilter(item:Object):Boolean > > > { > > > if(item.Phone.search(searchBar.text) >= 0) > > > {return true;} > > > else > > > {return false;} > > > } > > > > > > the 5 phone numbers that i randomly put in the collection are are > > > #1)"123-456-7890" > > > #2)null > > > #3)"(403)734-4312" > > > #4)"(780)495-4949" > > > #5)"(780)828-4229" > > > > > > the #1 and #2 phone number filters as expected however the ones > > with > > > the brackets are awkward. > > > "(", "(780", "780)", "(780)828" fail not as I expected > > > "(780)", "780" succeed as I expected > > > > > > And tossing in random "*" succeed definitely not as I had expected > > > "(780)*82" matches #5 > > > "(780)*8" or even "780*4*4*4*4*4*4*4*4*4*4*4*4*4*4*4*4*4*4*4*" > > matches > > > #4, #5, and #1 > > > "(780)*", or "(spam)*" match all 5 numbers > > > even "()*" or "(###)*" where # is any 3 numbers and it matches all > > 5 > > > numbers again even the null. > > > even "(828)" matches #5 or similar ideas > > > > > > Obviously the "(", ")" and "*" characters are doing something > > strange > > > to the search() function. Hopefully someone can explain why I'm > > seeing > > > this behavior with these characters or a way to change how I'm > > > filtering the phone numbers to get somewhat normal behavior. > > > > > >

