C# 如果判断网址是否正确,C#判断 URL是否正确,正则表达式
作者:笨笨 日期:2009-10-28
程序代码using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
namespace test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string websitereg = @"http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?";
Match w1 = Regex.Match(textBox1.Text, websitereg);
if (w1.Success)
{
MessageBox.Show("yes");
}
else
{
MessageBox.Show("no");
}
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
namespace test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string websitereg = @"http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?";
Match w1 = Regex.Match(textBox1.Text, websitereg);
if (w1.Success)
{
MessageBox.Show("yes");
}
else
{
MessageBox.Show("no");
}
}
}
}
评论: 0 | 引用: 0 | 查看次数: -
发表评论

上一篇
下一篇

文章来自:
Tags: