Hi All,
I have a string in a variable something like below
"Line1[0]: Bang\r\nLine2[0]: xyz\r\nCity[1]: hwjhdwj"
After parsing the string Now i want to remove the the contents [0] and [1]. After the manupulations it should give the output as
"Line1: Bang\r\nLine2: xyz\r\nCity: hwjhdwj"
Do anyone has any idea???
Thanks,
Prasant
String parsing
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


VulpesRank #55 · 29.2K reputationPosted Jul 17, 2012, 7:59 AM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 17, 2012, 7:40 PM EDT
you can also use Reges.Replace for same..
try
string input = "Line1[0]: Bang\r\nLine2[0]: xyz\r\nCity[1]: hwjhdw" ;
string pattern = @"\[0\]|\[1\]";
string replacement = "";
Regex rgx = new Regex(pattern);
string result = rgx.Replace(input, replacement);
hope this will help you.