What is the best way to check if a string contains an element from a list?
for example:
String email= 'itairu@gmail.com'
List<String> domainNames = split by ; from domains in a custom setting
for example : (domainNames = [0] - gmail.com, [1] - example.com, [2] - mof.com);
How can I check if email field is contains one of the values in the domainName's List?
I can do it with a Boolean field that will be turned to true if one of field is found for this case -
boolean found = false;
for(String s : domainNames ){
if(email.contains(s)){
found =true;
}
}
I want to know if there is a better way - in case I will have a huge amount of values to move on in the for loop for this.
Thanks!