问题
I just want to replace a particular text with blank space in RDLC column.
I want to replace .aspx with "" in every string.
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.
WHY ?
Update:
I used this but not working
=Replace(Fields!AuditsUserActivity.Value, "@"+".aspx", string.Empty)
回答1:
Use this simple code:
string result = Regex.Replace("x.aspx", @"\b.aspx\b", string.Empty);
回答2:
string inpString = "abcdeggggy.aspx";
string i = Regex.Replace(inpString ,@".aspx", "").Trim();
dont forget add using System.Text.RegularExpressions; namespace
回答3:
Try this
string sResult= System.Text.RegularExpressions.Regex.Replace("abc.aspx", @".aspx", "");
回答4:
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", "");
来源:https://stackoverflow.com/questions/33408066/how-to-find-and-replace-a-specific-word-in-string