简体   繁体   English

正则表达式中的卷曲括号{}

[英]Curly Brackets in Regex Expression { }

just want to ask the right expression for curly bracket 只想问正确的表达式为花括号

output should be all text inside { and ends with } will all be color blue . 输出应该是{和}之内的所有文本都将是蓝色。 not a single line but all text inside curly brackets even if its different line . 不是单行,而是大括号内的所有文本,即使它的行不同。

further more something like this1: 更多像这样的东西1:

int csharp = rtb.SelectionStart;
Regex bracket = new
Regex("\'[^\"]*\'");

foreach (Match brack in bracket.Matches(rtb.Text))
{
    rtb.Select(brack.Index, brack.Length);
    rtb.SelectionColor = Color.Blue;
    rtb.SelectionStart = csharp;
    rtb.SelectionColor = Color.Black;
}

expression above was for singlequote . 上面的表达式是单引号。 all text inside ' ' (sample 'text') will all be color blue . ''(示例'文本')中的所有文本都将为蓝色。 i need for the curly brackets thanks . 我需要大括号谢谢。

starts with { and ends with } 以{开头}结尾

这应该适合你:

Match match = Regex.Match(yourString, @"{[^}]*}");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM