I am looking for a regular expression that can help me search a list of email strings such that say, if I have an arraylist
with a couple of emails listed such that : firstname.lastname@company.com
, firstname1.lastname1@company.com
I would like to search through them such that in my filter if I add rst name1
,it will display firstname1.lastname1@company.com
, I have the filter code in place and it searches thru every matched letter. however I would like to modify it and make it search the characters before or after the dot "." with regular expressions. How do I go about it?
Here's my filter search code :
protected synchronized FilterResults performFiltering(CharSequence constraint) {
FilterResults results = new FilterResults();
if (constraint != null && constraint.length() > 0) {
ArrayList<Integer> filterList = new ArrayList<>();
int iCnt = listItemsHolder.Names.size();
for (int i = 0; i < iCnt; i++) {
if(listItemsHolder.Types.get(i).toString().indexOf("HEADER_")>-1){
continue;
}
if (listItemsHolder.Names.get(i).toLowerCase().contains(constraint.toString().toLowerCase())) {
if(filterList.contains(i))
continue;
filterList.add(i);
}
}
results.count = filterList.size();
results.values = filterList;
}else {
results.count = listItemsHolder.Names.size();
ArrayList<Integer> tList = new ArrayList<>();
for(int i=0;i<results.count;i++){
tList.add(i);
}
results.values = tList;
}
return results;
}
//Invoked in the UI thread to publish the filtering results in the user interface.
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
ArrayList<Integer> resultsList = (ArrayList<Integer>)results.values;
if(resultsList != null) {
m_filterList = resultsList;
}
notifyDataSetChanged();
}
}
where
class ListItemsHolder {
public ArrayList<String> Names;
}
contains all the necessary names in the format firstname.lastname@company.com