简体   繁体   English

如何在ASP.NET C#中替换单引号

[英]How to replace single quote in asp.net c#

I used Regex.Replace(jobdesc, @"[^\\/\\'-]+", " "); 我用了Regex.Replace(jobdesc, @"[^\\/\\'-]+", " "); but its not working please help me I want to replace only (' and -) with blank space how to arrange this regex code. 但它不起作用,请帮我,我想只用空格替换('和-)如何排列此正则表达式代码。

您可以使用一个简单的替换,如:

"your sentence".Replace("''"," ").Replace("-"," ");

Using Reg Exp you can do as below 使用Reg Exp您可以执行以下操作

string pattern = @"\-\'";
    string input = "mynam-'is";
    string replacement = " ";
    Regex rgx = new Regex(pattern);
    string result = rgx.Replace(input, replacement);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM