[英]C# Regex to remove single quotes between single quotes
Hi guys i want to remove all single quotes between single quotes using C# regex, example 嗨,大家好,我想使用C#正则表达式删除单引号之间的所有单引号
'this is an 'example' text' “这是一个“示例”文字”
Note that word example is between single quotes. 请注意,单词示例位于单引号之间。 I need that my string looks like: 我需要我的字符串看起来像:
'this is an example text' “这是示例文字”
Thanks! 谢谢!
EDIT: 编辑:
It have some changes! 它有一些变化! now the string look like: 现在字符串看起来像:
begin:'this is an 'example' text' 开始:“这是一个“示例”文字”
Note that the string now start with a word followed by : and then the first single quote ' 请注意,该字符串现在以单词开头,后跟: ,然后是第一个单引号'
You don't need to use regex (and it's not very well suited to this situation anyway). 您不需要使用正则表达式(反正也不适合这种情况)。 Try this instead: 尝试以下方法:
string oldString = "'this is an 'example' text'";
string newString = "'" + oldString.Replace("'","") + "'";
Based on your comments: 根据您的评论:
string yoursentence = "'this is an 'example' text'";
yoursentence = "'" + yoursentence.Replace("'","") + "'";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.