2016-11-18
工具:Visual Studio 2015 with Update 3
WinForm 的 Form1.cs 內容
using System; using System.Text.RegularExpressions; using System.Windows.Forms; namespace WindowsFormsApplication4 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { richTextBox2.Text = RemoveHTMLTag(richTextBox1.Text); } public static string RemoveHTMLTag(string htmlSource) { htmlSource = Regex.Replace(htmlSource, @"<script[\d\D]*?>[\d\D]*?</script>", String.Empty); htmlSource = Regex.Replace(htmlSource, "<[^>]*>", String.Empty, RegexOptions.IgnoreCase); return htmlSource; } } } |
(完)
沒有留言:
張貼留言