如何查找和替换字符串中的特定单词? [英] How to find and replace a specific word in string?

查看:28
本文介绍了如何查找和替换字符串中的特定单词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想用 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", "");

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆