大家好,我想使用 C# 正则表达式删除所有单引号之间的单引号,示例
'this is an 'example' text'
请注意单词example 位于单引号之间。我需要我的字符串看起来像:
'this is an example text'
谢谢!
编辑:
它有一些变化!现在字符串看起来像:
begin:'this is an 'example' text'
请注意,字符串现在以一个单词开头,后跟 :,然后是第一个单引号 '
最佳答案
您不需要使用正则表达式(而且它不太适合这种情况)。试试这个:
string oldString = "'this is an 'example' text'";
string newString = "'" + oldString.Replace("'","") + "'";
关于C# Regex去除单引号之间的单引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12012966/