Hallo can any one help me please,
i want to delete data present in Comments
Forexample:
//#define 0
//#define 1
/*#define 2*/
/*#define 3
#define 4*/
#define 5
/* abcd
*/
// efgh
// #define 6
#define 7
/* #define 8
#define 9
// #define 10
output should be:
#define 5
#define 7
#define 9
i tried thisway,
string line; string str;
StringBuilder sb = new StringBuilder();
// Read the file and display it line by line.
using (System.IO.StreamReader file = new System.IO.StreamReader("FilePath"))
{
while ((line = file.ReadLine()) != null)
{
if (line.Contains("#define"))
{
str = line;
sb.AppendLine(line.ToString());
}
}
}
str = sb.ToString();
string pattern = @"(//[\t|\s|\w|\d|\.]*[\r\n|\n])|([\s|\t]*/\*[\t|\s|\w|\W|\d|\.|\r|\n]*\*/)|(\<[!%][ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t%]*)\>)";
Regex rx = new Regex(pattern, RegexOptions.IgnoreCase);
MatchCollection mc = rx.Matches(str);
foreach (Match m in mc)
{
str = str.Replace(m.Value, "");
MessageBox.Show(str);
}
but am not able to read all till file end, it reads upto #define 10 , there is a one line empty ,its stopping there, i want to read all data between #define and delete comment's data, thanks