How do I filter the records of a Array
by using the search terms separated by spaço ?
Example:
I have a% of String% with the following records.
- bottle opener
- box with blue padlock
- 30mm brass padlock with 03 keys
- 100mm screwdriver
- padlock game with 02 keys
- cloth to clean sink
- garden faucet
In the filter field, the user types only cha cha , this search should only return the records.
- 30mm brass padlock with 03 keys
- padlock game with 02 keys
To try to solve this problem, a function with Array
was created to read record by for
. For each record I tried to use the regular expression "(cade | chav)" it filters the following products;
- box with blue padlock
- 30mm brass padlock w / 03 yellow keys
- 100mm screwdriver
- padlock game with 02 keys
But bold items should not appear.
Another thing that should be taken into account, the user can type only "padlock", or "cad brass keys", or "blue" or with one or more words in the filter, until then I know that I will have to assemble the expression dynamically as "(cade | chav)" or "(cad | brass | keys)" or "(azu)" etc.
If there is another way to solve this problem in java without using regular expression it will also be coming.