小工具
随手写的html代码转C语言数组的小工具,记录一下
关键代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| private void button1_Click(object sender, EventArgs e) { string html = textBox1.Text; string[] htmlArr = html.Split('\n'); for (int i = 0; i < htmlArr.Length; i++) { if (htmlArr[i] != "") { htmlArr[i] = System.Text.RegularExpressions.Regex.Replace(htmlArr[i], "\\s{2,}", ""); htmlArr[i] = htmlArr[i].Replace("\t", ""); htmlArr[i] = "\"" + htmlArr[i] + "\\r\\n\""; } } textBox2.Text = string.Join("\r\n", htmlArr); textBox2.Text = "const char Html_login[]={\r\n" + textBox2.Text + "\r\n};"; }
|
github仓库