如何使用C#Windows窗体在(-)左侧剪切字符串 [英] how to cut string on left side of (-) using c# windows form
本文介绍了如何使用C#Windows窗体在(-)左侧剪切字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的文本框中的字符串如下所示
I have text box have string as following
法国-فرنسا
我只需要获取法国的字符串
I need to get the string of France only
表示我需要在-的左侧获取任何字符串.
meaning i need to get any string in left side of -
意味着我需要得到
来自
法国-فرنسا
仅获得法国
如何使用c#Windows窗体vs2015做到这一点
How to make that using c# windows form vs2015
推荐答案
解决方案之一:
One of the solutions:
string example = "France - فرنسا"; // or textBox1.Text
string result = Regex.Match( example, @"^.+?(?=\s*-)" ).Value;
这篇关于如何使用C#Windows窗体在(-)左侧剪切字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文