So you’re looking for the name with “deal” or “bitte” in it?
Then you could do something like
person_list.each do |name|
return name if name.split.any? do |name_part|
[‘deal’, ‘bitte’].any? {|keyword| name_part.casecmp(keyword) == 0}
end
nil
end
This will split the name on spaces and check if any part is “deal” or
“bitte”, ignoring the letter case. If there’s any match, this name is
returned. If no name matches, nil is returned instead (you may also use
person_list.first or so).
The excel_value is a variable . It can contain 1 or 2 or 3 or 4 words
too
Jan E. wrote in post #1069310:
Hi,
So you’re looking for the name with “deal” or “bitte” in it?
Then you could do something like
person_list.each do |name|
return name if name.split.any? do |name_part|
[‘deal’, ‘bitte’].any? {|keyword| name_part.casecmp(keyword) == 0}
end
nil
end
This will split the name on spaces and check if any part is “deal” or
“bitte”, ignoring the letter case. If there’s any match, this name is
returned. If no name matches, nil is returned instead (you may also use
person_list.first or so).
def default_person(excel_value,person_list)
person_list.each do |name|
selected_name= name if name.split.any? do |name_part|
excel_value.split.any? {|keyword| name_part.casecmp(keyword) ==
0}
end
nil
end
# puts(selected_name)
return selected_name # i will send the id of the selected name
at the end
end