Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在c语言中定义正则表达式#_C#_Regex_Migration_Migrate - Fatal编程技术网

C# 如何在c语言中定义正则表达式#

C# 如何在c语言中定义正则表达式#,c#,regex,migration,migrate,C#,Regex,Migration,Migrate,我需要使用regex替换源代码文档中的所有字符串,如下所示: strcpy(x,“字符串就是字符串”)been\u tcscpy(x,\u T(“字符串就是字符串”) 实际上,我需要用T_marco包围函数中的所有字符串 如何在c#中定义正则表达式模式来实现这一点? 谢谢如果您需要这样做,您可以使用要替换的strcpy(x,“string is string”)和\u tcscpy(x,\u T(“string is string”))从编辑菜单运行替换作为替换,设置“整个项目”。首先,在类中导

我需要使用regex替换源代码文档中的所有字符串,如下所示:
strcpy(x,“字符串就是字符串”)
been
\u tcscpy(x,\u T(“字符串就是字符串”)
实际上,我需要用T_marco包围函数中的所有字符串
如何在c#中定义正则表达式模式来实现这一点?

谢谢

如果您需要这样做,您可以使用要替换的strcpy(x,“string is string”)
\u tcscpy(x,\u T(“string is string”))从编辑菜单运行替换作为替换,设置“整个项目”。

首先,在类中导入正则表达式的API以供使用:

using System.Text.RegularExpressions;
第二步,在方法中实例化新的正则表达式:

Regex regexName = new Regex(@"string of regexExpression", RegexOptions.IgnoreCase);
第三,分析字符串或提取字符串的首选部分:

MatchCollection nameOfResult = regexName.Matches(this.yourString);
foreach (Match result in nomeOfResult)
        {
            System.out.println(result.ToString());
        }
第三个,如果替换与正则表达式对应的字符串的一部分:

Regex.Replace(yourString, regexName);
尝试以下模式:strcpy.*x、*string.*is.string。
对于模式或测试模式,请使用this:或this:

实际上,我需要在字符串“string is string”周围加上T_marco。