求一个简单的正则表达式

hgamezoom 2009-11-24 05:25:53
要求找出以下类型的字符串:

\\xxx\xx\xx\xx.doc

必须以\\开头,中间至少有1个\,xx代表任意数量的字母,数字或者空格,最后以.doc结尾。




在线等,感谢!





...全文
56 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
cnmcxiari 2009-11-24
  • 打赏
  • 举报
回复
用什么语言
十八道胡同 2009-11-24
  • 打赏
  • 举报
回复
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 . . .
fus53 2009-11-24
  • 打赏
  • 举报
回复
\\\\(\d|\w| |\\)+\\\1\.doc

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧