作者cole945 (躂躂..)
看板C_Sharp
标题Re: [问题] RegEx
时间Wed Mar 26 18:08:10 2008
※ 引述《thorita (燃烧殆尽)》之铭言:
: 我想要用 RegEx 去过滤路径
: ex:
: C:\Windows\xxx\ooo\中文档名
: 我想把前面那一串都过滤掉 只留下中文档名那串
: (\\|[0-9]|[A-Z]|[a-z]|:|-|_)*
你这样写的话, 自然会把 '\' 给算进去..
如果想用 regular expression的话, 要用 lookaround 来作
看 lookaround 来作
http://www.regular-expressions.info/refadv.html
不过这样都太麻烦了,
其实用
string name = Path.GetFileName( @"C:\Windows\xxx\ooo\中文档名" );
这样 name 就是 "中文档名" 了..
Path、File、Directory 有蛮多小工具可以用的..
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.139.184.121