- Home /
Search button filter
Hi all,
i am building a search filter into my button. when i press it i want it to remove all the words that don't match and only keep the one that matches. this is in Javascript.
any idea how i can do this?
thanks for any help
Answer by qJake · May 31, 2010 at 08:25 PM
Have an array of strings, and filter them out using regular expressions.
http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx
For instance, if you had this list:
- apple
- apartment
- dog
- market
- snap
and you typed in "ap", using the regular expression:
.*ap.*
it would find the following matches:
- apple
- apartment
- snap
The RegEx class can be found in the System.Text.RegularExpressions
namespace.
my prob is not matching but removing the ones that dont match
You don't remove the ones that don't match. You only display the ones that DO match. And yes, it will work with Javascript.
where i match it is in a seperate function than where i display it, i display it in OnGui and so it does'nt get updated.
Your answer
Follow this Question
Related Questions
Searching buttons with inputfield. 1 Answer
How to filter items in a scroll list, using a search bar? 1 Answer
Android: Search button event 0 Answers
Search gameobject by tag and filter box. 0 Answers