我有以下声明:
(( { dbo.Document.MimeType_ID in (select ID from MimeType where Name ='PDF')} Or { dbo.WorkflowItem.CurrentStateName not like 'On_Hold%'} ) And ( { dbo.DocumentMetaData.Field_ID=74 And dbo.DocumentMetaData.FieldValue Not like '%test%'} And { dbo.Document.FileName='karan'} ))
我想在{}
之间发表4条陈述例如
dbo.Document.MimeType_ID in (select ID from MimeType where Name ='PDF')
dbo.WorkflowItem.CurrentStateName not like 'On_Hold%'
dbo.DocumentMetaData.Field_ID=74 And dbo.DocumentMetaData.FieldValue Not like '%test%'
dbo.Document.FileName='karan'
答案 0 :(得分:1)
此正则表达式将起作用(如果没有嵌套模式)
\{\s*([^}]+)\s*\}
C#代码
string input = "(( { dbo.Document.MimeType_ID in (select ID from MimeType where Name ='PDF')} Or { dbo.WorkflowItem.CurrentStateName not like 'On_Hold%'} ) And ( { dbo.DocumentMetaData.Field_ID=74 And dbo.DocumentMetaData.FieldValue Not like '%test%'} And { dbo.Document.FileName='karan'} ))";
string pattern = "\\{\\s*([^}]+)\\s*\\}";
Regex rgx = new Regex(pattern);
Match match = rgx.Match(input);
while (match.Success)
{
Console.WriteLine(match.Groups[1].Value);
match = match.NextMatch();
}
<强> Ideone Demo 强>