How to check if any words in a list contain a partial string?

后端 未结 2 1232
天涯浪人
天涯浪人 2021-02-13 15:10
    var list=alist.Contains(\"somestring\")

this matches whole string, how to see if any word in list has a substring matching \"somestring\"?

2条回答
  •  清歌不尽
    2021-02-13 15:54

    var hasPartialMatch = alist.Split(' ').ToList()
          .Any(x => x.Contains("somestring"));
    

提交回复
热议问题