sampath meka

sampath meka

  • NA
  • 41
  • 11.7k

Regular Expressions

Feb 18 2014 1:15 AM
Hello All,
 
             I am new to C#  kindly help me with the Expected output:
 
What i have Done...
 
string strCombination = "((B48B20, XB1141) + PLUGIN_HYBRID + ECE), (B57D30 + TL + ECE), (B58B30 + ML + KEIN_HYBRID + ECE), (B57D30 + SL + US)";
string strCombination_Pattern = @"\((.*?)\)";
Regex rgx1 = new Regex(strCombination_Pattern, RegexOptions.IgnoreCase);
MatchCollection matches1 = rgx1.Matches(strCombination);
if (matches1.Count > 0)
{
foreach (Match match in matches1)
 
Console.WriteLine(match.Value);
}
}
 
Output:
 match.Value = (B48B20, XB1141) ,(B57D30 + TL + ECE),(B58B30 + ML + KEIN_HYBRID + ECE),(B57D30 + SL + US)
 
 
Expected output:
(B48B20, XB1141)+ PLUGIN_HYBRID + ECE ,(B57D30 + TL + ECE),(B58B30 + ML + KEIN_HYBRID + ECE),(B57D30 + SL + US) 
 
 
Thank u 
Sampath
 
 

Answers (13)