how do i find a pattern in richtextbox??

the text is like :

hello i want to {help|meet|call} you {please|come|soon}.

i want to find all such strings which have curly braces and then replace the whole string with any word from within it, RANDOMLY.

so on the click of a button the above line might become :

hello i want to help you please.
OR
hello i want to call you soon.

i thought of using regex but iam completely blank on how to use it, also i didnt understand some tutorials on google.

this method works

Random r = new Random();
        private void butRegex_Click(object sender, EventArgs e)
            {
            string stringWithTextIn = "hello i want to {help|meet|call} you.";
            Regex regex = new Regex(@"({.*})");
            string r = regex.Replace(stringWithTextIn, new MatchEvaluator(ReplaceMatch));
            MessageBox.Show(r);
            }
        string ReplaceMatch(Match m)
            {
            string s = m.Value;                     // Get matched text only
            s = s.Substring(1, s.Length - 2);       // Remove '{' and '}'
            string[] parts = s.Split('|');          // Break into words
            return parts[r.Next(0,parts.Length)];   // return randow word
            }

but it works only when there is one variation i.e for sentences like

hello i want to {help|meet|call} you.

any idea what is wrong??

Dim reg As New Regex(stringWithTextIn, RegularExpressions.RegexOptions.IgnoreCase Or RegularExpressions.RegexOptions.Singleline)
		Dim _match As MatchCollection = reg.Matches("my loaded text comes here")

		If _match.Count = 0 Then Return

		For Each match As Match In _match
			'call ReplaceMatch or whatever you want 
		Next
This article has been dead for over six months. Start a new discussion instead.