gpt4 book ai didi

C# Regex去除单引号之间的单引号

转载 作者:太空宇宙 更新时间:2023-11-03 17:55:33 30 4
gpt4 key购买 nike

大家好,我想使用 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/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com