List<string> results = new List<string>();
Regex regex = new Regex("abc");
MatchCollection matches = regex.Matches("123abc4abcd");
foreach (Match match in matches){
results.Add(match.Value);
}
var count = results.Count();
var rnd = new Random();
int s = rnd.Next(0,count);
for(int i=s; i<=s; i++){
var str = results[i];
project.Variables["asdf"].Value = str.Trim();
}