using System;
using System.Text.RegularExpressions;namespace Samples
{
public class RegExMatcher
{
public static void Main(String[] args)
{
Regex source = new Regex("\\(aspnet\\)");
String s = "(aspnet)(j2ee)"; if ( args.Length > 0 )
{
s = args[0];
} MatchCollection mc = source.Matches(s); if ( mc.Count >= 1)
{
foreach (Match m in mc)
{
System.Console.WriteLine(" " + m.Value);
} }
else
{
System.Console.WriteLine(s + " is not a valid email address");
} System.Console.WriteLine();
System.Console.WriteLine("Press Enter to Continue...");
System.Console.ReadLine();
}
}
}
using System.Text.RegularExpressions;namespace Samples
{
public class RegExMatcher
{
public static void Main(String[] args)
{
Regex source = new Regex("\\(aspnet\\)");
String s = "(aspnet)(j2ee)"; if ( args.Length > 0 )
{
s = args[0];
} MatchCollection mc = source.Matches(s); if ( mc.Count >= 1)
{
foreach (Match m in mc)
{
System.Console.WriteLine(" " + m.Value);
} }
else
{
System.Console.WriteLine(s + " is not a valid email address");
} System.Console.WriteLine();
System.Console.WriteLine("Press Enter to Continue...");
System.Console.ReadLine();
}
}
}
你试试这样?