How to use a wildcard when searching a dataset

Posted on 2005-04-14
Last Modified: 2011-09-20
Here is some code that I'm using:

Search_btn.onPress = function() {
      if (this._parent.ReasonCode_ds.hasSort("Category")) {
      var SearchID:String = null;
      if (this._parent.ReasonCode_ds.findFirst([this._parent.Search_txt.text])) {
       SearchID = this._parent.ReasonCode_ds.getItemId();
      } else {

I want to be able to use a wild card when entering text into the --- Search_txt --- component. (i.e. "Lost *")

So, if I have multiple instances in the dataset of the word "Lost" and I want to do a search for all instances normally I would use something like "Lost *", however for some reason if I enter "Lost" or "Lost *" the search fails. I have to put in the exact phrase that is in the dataset before I get a successful search (i.e. "Lost Keys") if "Lost Keys" is one of the items in the data set then the search works.

I sure hope someone out there can help. It doesn't seem logical to have to do a search for an exact phrase when the user may not know what the exact phrase is in the dataset!

Question by:gemarti
    LVL 18

    Accepted Solution

    try using indexof

    myString  .indexOf(  substring,  [ startIndex ] )

    LVL 21

    Author Comment

    Thanks Billystyx.....

    I'm not really sure I follow your suggestion.

    If I use the myString.indexOf(string,index) method then It looks like I'm have to iterate through each dataSet record, store the record to a string variable, evaluate for a match then store the index value to another variable. That seems a bit too time consuming. Is that what you are suggesting I do?

    I can try, but if there is a better solution out there, I'd love to see it.
    LVL 18

    Expert Comment

    It is the only way I am aware of, gemarti. Hope it is enough to work for you.


    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
    The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
    In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
    The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now