using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Globalization; using System.IO; using System.Data.SqlClient;namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string[] str = new string[] { @"\\xxx\xx\xx\xx.doc",@"\\xxx\xx.doc",@"\\xxx\xx\xx\xx.dox" }; Regex re = new Regex(@"^(?i)\\\\[ 0-9a-z]+(\\[ 0-9a-z]+)+\.doc$"); foreach (string s in str) { if(re.Match(s).Success) Console.WriteLine(re.Match(s).Value); } } } } \\xxx\xx\xx\xx.doc \\xxx\xx.doc Press any key to continue . . .
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using System.IO;
using System.Data.SqlClient;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string[] str = new string[] { @"\\xxx\xx\xx\xx.doc",@"\\xxx\xx.doc",@"\\xxx\xx\xx\xx.dox" };
Regex re = new Regex(@"^(?i)\\\\[ 0-9a-z]+(\\[ 0-9a-z]+)+\.doc$");
foreach (string s in str)
{
if(re.Match(s).Success)
Console.WriteLine(re.Match(s).Value);
}
}
}
}
\\xxx\xx\xx\xx.doc
\\xxx\xx.doc
Press any key to continue . . .