Reputation: 127
im trying to search into a IconsGroup in my application some elements with a "code", using a TextInput and validating if contains the code of any icons in the group.
if(iconsGroup.numElements > 0) {
for(var i:int = 0; i<iconsGroup.numElements; i++) {
if(iconsGroup.getElementAt(i) is R_VO) {
if((iconsGroup.getElementAt(i) as R_VO)._extintores != null
&& (txtBuscar.text.indexOf((iconsGroup.getElementAt(i) as R_VO)._extintores._codigo)) > -1) {
shake_AfterSearch(i);
}
}
}
But my problem right now is if I search a text:
"Code_1"
and
"CODE_1"
Exists a way to search it and find both Icons with the code "Code_1" or "CODE_1"?, I want to search it without case sensitive
Upvotes: 0
Views: 44
Reputation: 1857
You just need to use toLowerCase()
on strings. In your case it will be looked next:
var buscarText:String = txtBuscar.text.toLowerCase();
var searchedText:String;
if(iconsGroup.numElements > 0) {
for(var i:int = 0; i<iconsGroup.numElements; i++) {
searchedText = (iconsGroup.getElementAt(i) as R_VO)._extintores._codigo.toLowerCase();
if(iconsGroup.getElementAt(i) is R_VO) {
if((iconsGroup.getElementAt(i) as R_VO)._extintores != null
&& (buscarText.indexOf(searchedText)) > -1) {
shake_AfterSearch(i);
}
}
}
Upvotes: 2