简体   繁体   English

正则表达式在第一次出现后删除字符串中的;#

[英]Regex to remove ;# in string after first occurance

I need help in building a regex to help me remove ;# in a string and replace it with a , after the first occurrence. 我需要构建正则表达式的帮助,以帮助我删除字符串中的;#并在第一次出现后用a代替。 For the first occurrence of the the ;# I want to remove it and subsequent ;# I want to replace with a ,. 对于第一次出现的;#,我想将其删除,随后的;#我要替换为,。 An example of what I am looking for is below: 下面是我正在寻找的示例:

;#something@domain.com;#something2@domain2.com;#

needs to end up being: 需要最终成为:

something@domain.com,something2@domain.com

replace ";#" with "," and then trim the first and the end "," 将“;#”替换为“,”,然后修剪第一个和最后一个“,”

string input = ";#something@domain.com;#something2@domain2.com;#";
string afterEdit = input.Replace(";#", ",").TrimStart(',').TrimEnd(',');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM