-1

I'm trying to process text in a file and get the substring within a string. This involved me getting into regular expressions for the first time. I'm trying to get an array of strings from within one giant string. Say for instance,there is

string test = "Thing {goalOne} Thing {goalTwo}";

I'm hoping to get a result like this if it was written out in code

string[] result = {"goalOne", "goalTwo"}

What I've tried so far:

Splitting it up into pieces and capturing the group inside

string[] result = Regex.Split(test, "Thing {()}");

Captureing the method within the group

 Regex filter = Regex("Thing{()}")
 string[] result = Regex.Match(test).Groups.Value;

And both have gave me one long string like "goalOnegoalTwo" or didn't work at all respectively. This is my first time with RegEx so any explanation will be appriciated. Thanks for your time.

0 Answers0