Regex Replace
I am having a problem in getting this regext statement to work. I exp3ect the Q: in the a.FullPath to be removed but it isn't happening. Any ideas why?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Lajapathy ArunPosted May 4, 2012, 3:22 PM
using System;
using System.Text.RegularExpressions;
namespace RegexReplaceForum
{
public partial class regexClassMy : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string fullPath = @"Q:\1111_drop1.TXT";
string replaceStr=Regex.Replace(fullPath, "Q:", "");
}
}
}
replaceStr variable Output:\1111_drop1.TXT
Roy SPosted May 4, 2012, 3:20 PM
So instead of
FullPath2 = Regex.Replace(a.FullPath, "Q:", "");
Try this:
FullPath2 = a.FullPath.Replace("Q:", "");