【发布时间】:2015-07-27 19:28:12
【问题描述】:
我正在尝试在任何 Non Word Characters (\W) 上拆分字符串,包括 spaces 但不包括以下字符:.、_、$。我也在尝试保留任何Regex.Split的分隔符除了为spaces
我该怎么做?我读过很多问题,但这没有意义。这是我最新的代码:
string[] result = Regex.Split (source, @"(\W[^(.|_|#|$)])");
编辑:
这里是一个例子
using System.Text;
我想要:
using _ System.Text _ ;
(当前)结果是:
__using_System.Text_;_
【问题讨论】:
-
你需要用 `\` 转义它们。
-
请包含一个示例输入和输出。
标签: c# regex regex-negation