i think this would be really silly question , but iam not succesful with extratic srtings those within the angular barkets in a sentence .
var str = "MR. {Name} of {Department} department stood first in {Subjectname}"
i need to obtain the substrings (as array) those are within the angular brakets
like strArray should contain {Name,Department,Subjectname} from the above given string
Noting the use of var
in your question, I will assume that you are using .NET 3.5.
The one line of code below should do the trick.
string[] result = Regex.Matches(str, @"\{([^\}]*)\}").Cast<Match>().Select(o => o.Value).ToArray();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With