搜索(匹配)字符串中的多个单词!-C# [英] Search (match) multiple words in a string!-C#

查看:60
本文介绍了搜索(匹配)字符串中的多个单词!-C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们有人告诉我如何在特定字符串中找到两个或三个字的阶段。

例子



String = C Sharpe,F sharp,A主要代码。



假设我想在特定的刺痛中搜索单词c Sharpe(忽略区分大小写)

我使用了以下方法,但它确实不适用于两个单词阶段。





 {
if (dropdownSuppliar.Text.ToString()。Trim()。Contains(dt.Rows [r] [ 0 ]。ToString()。Trim()))


{







所以如果有人能帮我解决这个问题,我会非常感激。

谢谢



删除了SHOUTING - OriginalGriff [/ edit]

解决方案

尝试相反的方法:您正在搜索下拉文本以查看是否包含DataTable值......


if (dropdownSuppliar.Text.ToLower()。IndexOf(searchStr.ToLower())> -1)
{

}


感谢originalGriff,它现在正在工作。我应该做其他方式,我的错误

非常感谢



 {
if (dt .Rows [r] [ 0 ]。ToString()。Trim()。包含(dropdownSuppliar.Text.ToString()。Trim()))


{


guys does anyone tell me how to find a two or 3 word phases in a particular string.
example

String = "C Sharpe ,F sharp , A major codes."

lets say I want to search the word "c Sharpe" in the particular sting (ignoring case sensitivity)
I used following method but it did nt work for two word phases I guess.


{
  if (dropdownSuppliar.Text.ToString().Trim().Contains(dt.Rows[r][0].ToString().Trim()))


{




so if anyone could help me on this matter I would be really appciated.
Thanks

[edit]SHOUTING removed - OriginalGriff[/edit]

解决方案

Try the other way around: You are searching your dropdown text to see if contains the DataTable value...


if(dropdownSuppliar.Text.ToLower().IndexOf(searchStr.ToLower()) >-1)
{

}


thanks originalGriff ,it is working now.I should do other way around ,My mistake
thanks a Lot

{
  if (dt.Rows[r][0].ToString().Trim().Contains(dropdownSuppliar.Text.ToString().Trim()))
					 
					
						{


这篇关于搜索(匹配)字符串中的多个单词!-C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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