字符串操作-按特定单词分隔 [英] String manipultaion - separating by specific word

查看:67
本文介绍了字符串操作-按特定单词分隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有如下所示的字符串,这是sql语句的where子句的一部分.

字符串str ="product.product_id = employee.text_1和product.code_1 = employee.text_2";

我想使用C#将其分为和".

您能帮我吗?

Hi,

I have string as given below , this is part of where clause of sql statement.

string str = "product.product_id = employee.text_1 and product.code_1 = employee.text_2";

I want to split this by ''and'' using C#.

Could you please help me

推荐答案

您可以使用以下代码拆分字符串.

You can use following code to split string.

string[] splitted = Regex.Split(value, "and");



并且您需要包括以下using指令才能使用Regex.



And you need to include following using directive to use Regex.

using System.Text.RegularExpressions;




希望有帮助!




Hope this help!


这篇关于字符串操作-按特定单词分隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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