Reputation: 4776
I have next string:
String a = "someThing({Some text}); OtherStuff({Other text});";
I need to get the text included in '{' and '}' inside the 'someThing({...})';
I wrote:
var data = Regex.Match(a, @"(?<=someThing\(\{).*?(?=\}\)\;)", RegexOptions.Singleline).Groups[0].Value;
But as a result in data I get the whole string 'a'. My expected result - "{Some text}"
Thanks for any advance.
Upvotes: 1
Views: 178
Reputation: 174864
The below regex would match zero or more characters but not of }
, or }
which was present just after to something({
(?<=someThing\({)[^{}]*
If you want the output to contain {}
braces then you need to get out the opening curly bracket from lookbehind.
(?<=someThing\(){[^{}]*}
Upvotes: 1
Reputation: 67988
(?<=someThing\()({[^{}}]*})
Try this.See demo.
http://regex101.com/r/jT3pG3/31
Upvotes: 0