我有以下输入字符串
some text ) more text
some text , more text
some text ! more text
some text ; more text
some text ? more text
some text . more text
some text)more text
some text,more text
some text!more text
some text;more text
some text?more text
some text.more text
some text )more text
some text ,more text
some text !more text
some text ;more text
some text ?more text
some text .more text
我正在使用 Regex.Replace 方法希望得到
some text) more text
some text, more text
some text! more text
some text; more text
some text? more text
some text. more text
some text) more text
some text, more text
some text! more text
some text; more text
some text? more text
some text. more text
some text) more text
some text, more text
some text! more text
some text; more text
some text? more text
some text. more text
但我的字符串保持不变。
这是我的课:
public class PunctionationSignsSpaceing : ILanguageRuleFormater
{
private string _pattern;
public PunctionationSignsSpaceing()
{
_pattern ="( *[),!;?.] *)";
}
public string FormatString(string str)
{
str = Regex.Replace(
str,_pattern,"$1",
RegexOptions.Multiline|RegexOptions.Compiled
);
return str;
}
}
我在这里做错了吗?(我对正则表达式有点陌生。)谢谢