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

How to find and replace a specific word in string?(如何查找和替换字符串中的特定单词?)
本文介绍了如何查找和替换字符串中的特定单词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我想在每个字符串中用 "" 替换 .aspx.

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

我试着写

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

它适用于这种线条

Page Applicants.aspx viewed 

但不适用于这些行:

Data added in Inspectors.aspx

即它从那些 .aspx 出现在中间的行中删除了 .aspx,但没有删除 .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.

为什么?

更新:

我用过但没用

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

推荐答案

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

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", "");

这篇关于如何查找和替换字符串中的特定单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)