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", "");
这篇关于如何查找和替换字符串中的特定单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何查找和替换字符串中的特定单词?
基础教程推荐
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- 如果条件可以为空 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 将数据集转换为列表 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
