I'm a C# beginner, trying to parse from html to md. the following is the error codes:
string dir = @"D:\parseconfig.txt";
string article = Console.ReadLine(); //pasted html
string[] html2md = null;
try
{
html2md = File.ReadAllLines(dir);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
if (html2md.Length % 3 == 1 && html2md[html2md.Length - 1] == "#end")
{
for (int i = 0; i < html2md.Length - 1; i += 3)
{
article = Regex.Replace(article, html2md[i + 1], html2md[i + 2], RegexOptions.IgnoreCase);
}
Console.WriteLine(article);
Console.ReadLine();
}
and the parseconfig.txt is as followed:
pLeft
<p [a-zA-Z0-9-_]*="[a-zA-Z0-9-_]*?"( [a-zA-Z0-9-_]*="[a-zA-Z0-9-_]*?")?>"
pRight
</p>
\n\n
b
</?b>
**
#end
but it doesnt work i dont know why
i've tried the following with correct outputs
for (int i = 0; i < html2md.Length - 1; i += 3)
{
Console.WriteLine(html2md[i]);
Console.WriteLine(html2md[i+1]);
Console.WriteLine(html2md[i+2]);
}
but i have no idea why it doesnt work in Regex.Replace