您的位置:首页 > 编程语言 > C#

在C#中使用正则表达式

2011-10-20 19:41 211 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Regular_Expression_1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(@"This will find a match for the regular expresson '[A-Z]\d'.");
Console.WriteLine("Enter a test string now.");

Regex myRegex = new Regex(@"[A-Z]\d", RegexOptions.IgnoreCase);
string inputString = Console.ReadLine();
Match myMatch = myRegex.Match(inputString);
Console.WriteLine("You entered the string '" + myMatch.ToString() + "'was found in the string you entered.");

Console.ReadLine();
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: