删除C#.net中文本框中的最后一个单词 [英] remove last words in textbox in C#.net

查看:317
本文介绍了删除C#.net中文本框中的最后一个单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我想删除文本框中的姓氏.
我们正在申请简历搜索.
如果我的搜索字符串(文本框)包含.net和asp.net以及and和and .....
然后,我想删除最后的"and",并且仅执行".net和asp.net"之类的搜索.
如何删除遗言





我使用了substring和trimend.但是它只删除了最后一个"and"

Hi i want to remove last words in my textbox.
we are doing the application for resume search.
If my search string(textbox) contains .net and asp.net and and and and.....
Then I want to remove last "ands" and search is to done like ".net and asp.net" only.
How can i remove last words





I used substring and trimend.but it removes only one last "and"

推荐答案

使用正则表达式字符串:和
Use regular expression string: and


string query = Regex.Replace(".net and asp.net and", @"and


", string.Empty, RegexOptions.IgnoreCase | RegexOptions.Singleline);
", string.Empty, RegexOptions.IgnoreCase | RegexOptions.Singleline);



输出将是:

".net和asp.net"

或将正则表达式字符串替换为\ w +



Output will be:

".net and asp.net "

Or replace regular expression string to \w+


这篇关于删除C#.net中文本框中的最后一个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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