如何查找和替换字符串中的特定单词?

时间:2022-10-05 19:19:18

I just want to replace a particular text with blank space in RDLC column.

我只想用RDLC列中的空格替换特定文本。

I want to replace .aspx with "" in every string.

我想在每个字符串中用“”替换.aspx。

I tried writing

我试着写作

=Replace(Fields!AuditsUserActivity.Value, ".aspx", "")

it works for this kinda lines

它适用于这种线条

Page Applicants.aspx viewed 

but not for these kinda lines:

但不是这些有点线:

Data added in Inspectors.aspx

i.e. it removed .aspx from those lines in which .aspx appears in in-between but not for those in which .aspx appears at the end of string.

即它从.aspx出现在中间的那些行中删除了.aspx,但是没有.aspx出现在字符串末尾的那些行。

WHY ?

为什么?

Update:

更新:

I used this but not working

我用过这个但没用

=Replace(Fields!AuditsUserActivity.Value, "@"+".aspx", string.Empty)

4 个解决方案

#1


0  

Use this simple code:

使用这个简单的代码:

string result = Regex.Replace("x.aspx", @"\b.aspx\b", string.Empty);

#2


0  

string inpString = "abcdeggggy.aspx"; string i = Regex.Replace(inpString ,@".aspx", "").Trim();

dont forget add using System.Text.RegularExpressions; namespace

不要忘记使用System.Text.RegularExpressions添加;命名空间

#3


0  

Try this

尝试这个

 string sResult= System.Text.RegularExpressions.Regex.Replace("abc.aspx", @".aspx", "");

#4


0  

Like many others have suggested, you should try using a regex expression. Perhaps try copying this exactly:

像许多其他人建议的那样,你应该尝试使用正则表达式。也许尝试完全复制这个:

=System.Text.RegularExpressions.Regex.Replace(Fields!AuditsUserActivity.Value, ".aspx", "");

#1


0  

Use this simple code:

使用这个简单的代码:

string result = Regex.Replace("x.aspx", @"\b.aspx\b", string.Empty);

#2


0  

string inpString = "abcdeggggy.aspx"; string i = Regex.Replace(inpString ,@".aspx", "").Trim();

dont forget add using System.Text.RegularExpressions; namespace

不要忘记使用System.Text.RegularExpressions添加;命名空间

#3


0  

Try this

尝试这个

 string sResult= System.Text.RegularExpressions.Regex.Replace("abc.aspx", @".aspx", "");

#4


0  

Like many others have suggested, you should try using a regex expression. Perhaps try copying this exactly:

像许多其他人建议的那样,你应该尝试使用正则表达式。也许尝试完全复制这个:

=System.Text.RegularExpressions.Regex.Replace(Fields!AuditsUserActivity.Value, ".aspx", "");