Have found the error: 

Here's the working code:
----------------------------------------------------------------------
public function liveSearch(searchString:String):RegExp {
    var regExSearchString:RegExp = new RegExp(searchString, 'i');
    return regExSearchString;
}

<mx:TextInput id="searchStringInput"/>
<mx:DataGrid id="dataGrid"
dataProvider="{externalXML.customer.(name1.match(liveSearch(searchStringInput.text)))}"
...
----------------------------------------------------------------------


Problem was that I have to return a :RegExp not a :String for the live
search function.

Stupid, Stupid me...

What i now have is very cool: a real LiveSearch feature with just a
few lines of code.





--- In [email protected], "alexander.marktl"
<[EMAIL PROTECTED]> wrote:
>
> Hey Gordon. Thanks for the answer.
> 
> I tried your suggestion, but it still won't work. 
> 
> I show once again what the problem is. 
> I'm a novice, please keep this in mind ;-)
> 
> 
> This one works but it's case-sensitive. (The function liveSearch is
> unnecessary in this case. I know.):
> ---------------------------------------------------------------------- 
> public function liveSearch(searchString:String):String 
> {
>     return searchString
> }
> 
> <mx:TextInput id="searchStringInput"/>
> <mx:DataGrid id="dataGrid"
>
dataProvider="{externalXML.customer.(name1.match(liveSearch(searchStringInput.text)))}"
> >
> ----------------------------------------------------------------------
> 
> 
> 
> If I add RegExs the troubles begin. I have a label to show what's
> the RegExs output and it's excatly what it should be. If the string is
> empty it works just fine. If I start typing it shows nothing.
> ---------------------------------------------------------------------- 
> public function liveSearch(searchString:String):String 
> {
>     if(searchString == '') {
>         return ''
>     }
>     else {
>     var regExSearchString:RegExp = new RegExp(searchString, 'i');
>     var searchTerm:String = regExSearchString.toString();
>     return searchTerm
>     }
> }
> 
> <mx:TextInput id="searchStringInput"/>
> <mx:DataGrid id="dataGrid"
>
dataProvider="{externalXML.customer.(name1.match(liveSearch(searchStringInput.text)))}"
> >
> ----------------------------------------------------------------------
> 
> 
> 
> I also tried a static variable but this one works neither.
> So, always when I trie to add RegExs over variables it causes problems.
> ----------------------------------------------------------------------
> public var test:RegExp = new RegExp('Stich',i);
> public var test1:String = test.toString();
> 
> <mx:DataGrid id="dataGrid"
> dataProvider="{externalXML.customer.(name1.match(test1))}"
> >
> ----------------------------------------------------------------------
> 
> 
> Does anybody know what the problem could be?
> Thanks for replies...
> 
> 
> 
> 
> 
> 
> 
> 
> --- In [email protected], "Gordon Smith" <gosmith@> wrote:
> >
> > If the search pattern is a variable, I think you must use a RegExp
> > constructor rather than the /.../ RegExp literal notation. In other
> > words, do
> >  
> >     new RegExp(searchString.text, "i")
> >  
> > instead of
> >  
> >     /searchString.text/i
> >  
> > - Gordon
> > 
> > ________________________________
> > 
> > From: [email protected]
[mailto:[EMAIL PROTECTED] On
> > Behalf Of alexander.marktl
> > Sent: Thursday, March 08, 2007 1:33 PM
> > To: [email protected]
> > Subject: [flexcoders] Regular Expression Problem
> > 
> > 
> > 
> > Hi there.
> > 
> > I'm trying to use regex for a search function. I want case-insensitive
> > search, so I'm using the regex: /ANYTEXT/i
> > 
> > This one does work, but I want to insert a searchString.text variable
> > instead of ANYTEXT. 
> > "/searchString.text/i" doesn't work. 
> > 
> > How can i do this?
> > 
> > Here's the code, if it helps:
> > 
> > <mx:TextInput id="searchString"/>
> > <mx:DataGrid
> > dataProvider="{externalXML.customer.(name1.match(/stich/i))}">
> > ...
> >
>


Reply via email to