C# 用于在word中使用的IF条件中标识合并字段的正则表达式

C# 用于在word中使用的IF条件中标识合并字段的正则表达式,c#,xml,regex,C#,Xml,Regex,我可以使用以下正则表达式在word文档中找到megefields EX: <<SAMPLEMERGEFIELD>> private static readonly Regex instructionRegEx = new Regex( @"^[\s]*MERGEFIELD[\s]+(?<name>[#\w]*){1} [\s]

我可以使用以下正则表达式在word文档中找到megefields

EX: <<SAMPLEMERGEFIELD>>

private static readonly Regex instructionRegEx =
        new Regex(
                    @"^[\s]*MERGEFIELD[\s]+(?<name>[#\w]*){1}               
                        [\s]*(\\\*[\s]+(?<Format>[\w]*){1})?                
                        [\s]*(\\b[\s]+[""]?(?<PreText>[^\\]*){1})?        
                        [\s]*(\\f[\s]+[""]?(?<PostText>[^\\]*){1})?",
                    RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline);
EX:
专用静态只读正则表达式指令正则表达式=
新正则表达式(
@“^[\s]*合并字段[\s]+(?[\w]*){1}
[\s]*(\\*[\s]+(?[\w]*){1})?
[\s]*(\\b[\s]+[“”]?(?[^\\]*){1})?
[\s]*(\\f[\s]+[“”]?(?[^\\]*){1})?“,
RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline);
如何找到像这样的IF条件中的合并字段

{=IF(<<MERGEFIELD>> >= 100,10,0)}
{=IF(>=100,10,0)}

既然它已经是单线了,你就不能只做“if\s”(.?)”