是否有可能编写一个lambda表达式,它将迭代对象数组并替换其中一个属性中的'X','Y',''和'Z'的所有出现?
例如
return query.Select(x => { x.SomePropertyName= x.SomePropertyName.Trim().Replace(' ', "_"); return x; }).ToList();
Run Code Online (Sandbox Code Playgroud)
出于某种原因,当我需要替换多个字符时,上面的查询不会替换单个字符.
谢谢
我想在字符串中找到所有特殊字符并替换为连字符(-)
我使用以下代码
string content = "foo,bar,(regular expression replace) 123";
string pattern = "[^a-zA-Z]"; //regex pattern
string result = System.Text.RegularExpressions.Regex.Replace(content,pattern, "-");
Run Code Online (Sandbox Code Playgroud)
富巴 - 正则表达式替换----
我在输出中得到多次连字符(---).
我想得到一些像这样的东西
FOO-BAR-正则表达式替换
我如何实现这一目标
任何帮助,将不胜感激
谢谢Deepu