如何查找字符串列表中是否存在子字符串(如果是,则在列表中返回全部值) [英] How to find if substring exists in a list of strings (and return full value in list if so)

查看:185
本文介绍了如何查找字符串列表中是否存在子字符串(如果是,则在列表中返回全部值)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在A5中有一个品牌名单:A7655
我有D5中的潜在子字符串列表:D1400



我需要找到一个相应的可能的每个子串的品牌名称。这些子串中的大多数都包含在品牌名单列表中的一个单元格中。在包含子串的列表中返回第一个品牌名称。



例如:D5中的子字符串是ABC Studios - 如果我搜索我的整个列表,我看到有一个品牌名称ABC Studios,LLC。在E5中,我想返回ABC Studios,LLC。如果列表中没有匹配返回0或某事没问题。



我玩过= ISNUMBER(SEARCH(A5,$ D $ 5:$ D $ 1400)),没有成功。谢谢!

解决方案

查找匹配字符串的最后一个实际上在公式方面更为简单:



= IFERROR(LOOKUP(2 ^ 15,SEARCH(D5,$ A $ 5:$ A $ 7655),$ A $ 5:$ A $ 7655),找不到匹配)



要查找第一个匹配的字符串:



= IFERROR(INDEX ($ A $ 5:$ A $ 7655,MATCH(TRUE,INDEX(ISNUMBER(SEARCH(D5,$ A $ 5:$ A $ 7655))),0)),找不到匹配)



关心


I have a list of brand names in A5:A7655 I have a list of potential substrings in D5:D1400

I need to find a corresponding brand name for each substring where possible. Most of these substrings are contained in one of the cells in the brand name list. Returning the first brand name on the list that constains the substring is fine.

For example: My substring in D5 is "ABC Studios" - if i search my whole list I see that there is a brand name "ABC Studios, LLC". In E5 I want to return ABC Studios, LLC. If there is no match in the list returning 0 or something is fine.

I played around with =ISNUMBER(SEARCH(A5,$D$5:$D$1400)) with no success. Thanks!

解决方案

Finding the last matching string is actually slightly more straightforward in terms of the formula:

=IFERROR(LOOKUP(2^15,SEARCH(D5,$A$5:$A$7655),$A$5:$A$7655),"No Match Found")

For finding the first matching string:

=IFERROR(INDEX($A$5:$A$7655,MATCH(TRUE,INDEX(ISNUMBER(SEARCH(D5,$A$5:$A$7655)),,),0)),"No Match Found")

Regards

这篇关于如何查找字符串列表中是否存在子字符串(如果是,则在列表中返回全部值)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆