本文介绍了[解决]正则表达式字符串拆分c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨专家,
Hi experts,
string Input = "@a = '1', @b = '[email protected],[email protected]'"
我想拆分输入字符串并希望输出如下使用正则表达式
I want to split Input string and want output as below using regex
ary[0] = a = '1'
ary[1] = b = '[email protected]'
我希望用@和它分开不应该用单引号
感谢adv。
I want to split by @ and it should not be in single quotes
thanks in adv.
推荐答案
string Input = "@a = '1', @b = '[email protected],[email protected]'"
string[] ary = Input.Split(',');
string Input = "@a = '1', @b = '[email protected],[email protected]'"
string Output = Regex.Split(Input, @"(?=@\w+[ =|=])@")
(条件)true | false
(condition)true|false
(?=@\w+[ =|=]) condition
@ if true then split by @
--condition work as below
? In supplied input What
= is equal to
@\w+ a(single) word that start with @
[ =|=] and after the word end it contain space+= or =
快乐编码!
:)
Happy Coding!
:)
这篇关于[解决]正则表达式字符串拆分c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!