在搜索字符串时需要帮助 [英] need help in searching a string

查看:93
本文介绍了在搜索字符串时需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

请告诉我如何也搜索包含空格的字符串...

例如如果我搜索什么是

那么它也应该计算空间,并在gridview中获取结果后,它应该突出显示整个搜索字符串..

解决方案

我们可以在sql中使用like运算符来获取解决方案服务器

从emp中选择*,其中empname =''%test t%''


假设您的搜索字符串为

 字符串 searcStr = " ; 



现在您要在段落中搜索此字符串;

 字符串 paragrph =  @" 您的第一个应用程序HelloApp将仅显示问候语"Hello world!"." ; 



 如果(paragrph.Contains(searcStr))
           Response.Write("  + paragrph.IndexOf(searcStr)+ " );


我不确定您是否已通过互联网搜索此内容.在C#中,可以使用String类的 Contains 方法或 IndexOf 方法并搜索子字符串.

Hi all

Please tell me how to search a string including space also...

e.g. if i search What is

then it should count the space also and after fetching the result in a gridview it should highlight the whole search string..

解决方案

We can get solution using like operator in sql server

select * from emp where empname=''%test t%''


Let say your search String is

string searcStr = "Hello world";



now you want to search this string in a paragraph;

string paragrph = @"Your first application, HelloApp, will simply display the greeting 'Hello world!'.";



if (paragrph.Contains(searcStr))
           Response.Write("The search string found at" + paragrph.IndexOf(searcStr)+" character position");


I am not sure whether you have searched for this over internet or not. In C# you can use Contains method or IndexOf method of the String class and search for a substring..


这篇关于在搜索字符串时需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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