.net - i want to find values between { } -


I am working with regular expressions (regesx), but I am not looking for exact output. I want to find values ​​between two curly braces

  {value} = value  

I use the following pattern but do not get accurate output I am doing; It does not delete "{" first ...

  string pattern = "\\ {* \\}";  

If my value returns {girish} then {girish

instead of me Girish as output ...

I wonder how to start this pattern Works - it should match zero or more relays. You need to group content within the content:

  string pattern = @ "\ {([^}] *) \} ";  

Then remove the matched content of the group. You did not show the code that you used to remove the output, but in this case it will be in group 1. For example:

  using the system; Using System.Text.RegularExpressions; Class test {static zero main () {string pattern = @ "\ {([^}] *) \}"; Reggae Reggae = new Reggae (Pattern); String text = "{key} = value"; Match Match = regex.Match (text); String key = match group 1]. Value; Console.WriteLine (key); }}  

Comments