Escaping Backslashes In String.replace?

Jan 25, 2011

I have an image control with the following string


I want to replace string cleartext=imagePath.Replace("","/"); but the backslash causes a problem -- how can I replace the backslash?

View 2 Replies

Similar Messages:

C# - Escaping Quotes In Json String?

Aug 12, 2010

System.Web.Script.Serialization.JavaScriptSerializer s = new System.Web.Script.Serialization.JavaScriptSerializer();
result = s.Deserialize<Hashtable>(data);
Error is thrown if data is "{a:""test" 123",b:"hello" }"
No error is thrown if data is "{a:"test 123",b:"hello" }"

How do I adjust the data string so that no error is thrown even when there are quotes?

View 1 Replies

Web Forms :: Regex.Replace - How To Replace All In A String

Jun 18, 2010

I need to replace <span> entries in a string to legacy html code because it's going to be used in a report for Crystal Reports. <b> works with Crystal, but the<span>'s do not.

Here's the string which I'm trying to replace: <span style="font-weight: bold">%THIS CAN BE ANY TEXT%</span>. I want to replace it to



View 5 Replies

Url Rewriting - Consecutive Are Backslashes Removed From Url?

Oct 28, 2010

I'm having an issue in my ASP.NET web app where intentionally consecutive backslashes are being removed from the request url.

I'll request something like:

But when the request hits the page, the raw url is:

Not sure if this is the culprit, but I do have a Url Rewite regex in place, here's the rule:


So, after the rewrite, the querystring is coming out as Page.aspx?1=A&2=C&3= When it should be Page.aspx?1=A&2=&3=C

View 1 Replies

Search And Replace String Value?

Jun 9, 2010

I have a string variable contain text that I would like to search for "Keyword" and replace it with new value.

For example:

Dim strValue = " col1 = "John" and col4 = "smith" or col7 <> "closed" or col9 > 1 and col5 = "passed" "

After the replace the strValue should be :

strValue = " col1 = "John" and ( col4 = "smith" or col7 <> "closed" or col9 > 1 ) and col5 = "passed" "

View 13 Replies

How To Replace Characters In String

Dec 1, 2010

i have a string and want to remove text up to the last forward slash, e.g

Should now be

How do i go about doing this?

View 2 Replies

C# - Replace String With A Control?

Feb 15, 2010

I have a string with special characters insert in different places. For example:

string myString = "This is a textbox: ##";

I would like to replace the ## with a control (namely, a textbox).

The Replace method only allows the string to be replaced with another string or character (understandably). But what would be the best way to dynamically replace the ## with a control in its position?

I was thinking maybe I could replace it with HTML markup which would be executed, but not quite sure how that would be achieved.

EDIT: To clarify some details. The strings are being retrieved from a database, so I can't use the PlaceHolder control. The user selects a string from a drop-down list. The value of the item is the string with special characters. When the postback occurs from the item selection, I would like to display the string on the site, but replace the special characters with a fully working control (in this case, a textbox)

View 5 Replies

C# Replace String Not Working?

Oct 4, 2010

// Build email link
confirmLink = Master.siteDomain + "/newsLetter.aspx?action=confirm&e=" + emailAddress + "&code=" + verCode;
using (SqlCommand cmd = new SqlCommand("SELECT newRegEmailBody, newRegEmailSubj FROM tblSiteSettings WHERE (isActive = 1)",
SqlDataReader rdr = cmd.ExecuteReader();
if (rdr.Read())
emailBody = rdr[0].ToString();
emailSubj = rdr[1].ToString();
emailBody.Replace("[CONFIRMATION_LINK]", confirmLink);
emailer.sendEmail(emailAddress, Master.noReplyEmail, emailSubj, emailBody);

It all seems to work fine, except the body is still showing up with [CONFIRMATION_LINK] in the text,

View 4 Replies

C# - Replace Char In A String?

Sep 13, 2010

how to change


One way i know is to use the string.replace(char, char) method,

but i want to replace "@" & "." The above method replaces just one char.

one more case is what if i have XX.X@YYY.ZZZ...

i still want the output to look like XX.X_YYY_ZZZ

View 8 Replies

Web Forms :: How To Replace String Using Regex

Jun 16, 2010

I am getting taggings like the following in a string

<color> vocation </color>
<color> elation </color>
<color> sage </color>

you can notice that each tagging differs only in the wordings


But i want to write a code some thing like this

Regex.Replace(userAx, "<color> vocation </color>",
"<color> </color>"

so that the resulting output does not contain words at the centre.In the above code instead of giving the word vocation exclusively, i have to mention some pattern, so that it will replace all the words instead of doing it for first sentence only.How to modify my code?

View 6 Replies

Finding Wildcard String Replace?

Oct 21, 2010

I am using a chat script I found for free online.

It allows a profanity filter by using string replace:

ex: ChatText.Replace("hell", "!@#$")

is there a way to do a wildcard replace? It doesn't catch the word "HELL" or "Hell" for example.

View 2 Replies

Replace Special Character From String?

Sep 16, 2010

txtPhoneWork.Text.Replace("_", "");
txtMobile.Text.Replace("-", "");
txtMobile.Text.Replace("_", "");
txtPhoneOther.Text.Replace("-", "");
txtPhoneOther.Text.Replace("_", "");
location.ContactWork = txtPhoneWork.Text.Trim();
location.ContactMobile = txtMobile.Text.Trim();
location.ContactOther = txtPhoneOther.Text.Trim();

but it is not replacing and is there any method so that both - and _ can be replaced in single function.

View 2 Replies

Web Forms :: Replace HTML Tag From String?

Apr 5, 2010

i have convert one of my Repeater to html format using Stringbulider and HtmlTextWriter. now i got html string. my repeater had some image Tags which i don't need it. so i want to replace the image tag(s) with empty sapce. i came to know its possible with using System.Text.RegularExpressions; Regex Thing is dont know how to find the all img tags from the string.

View 2 Replies

Find A String And Replace It More Efficiently

Jul 3, 2010

Situation: I have a html file and I need to remove certain sections. For Example: The file contains html:

<div style="padding:10px;">First Name:</div><div style="padding:10px; background-color: gray">random information here</div><div style="padding:10px;">First Name:</div><div style="padding:10px; background-color: gray">random information here</div>

I need to remove all text that starts with "<div style="padding:10px; background-color: gray">" and ends with "</div>" so that the result would be:

<div style="padding:10px;">First Name:</div><div style="padding:10px;">First Name:</div>

I created 2 functions that do this, but I do not this it efficient at all. I have a 40mb file and it takes the program about 2 hours to complete. Is there a more efficient way to do this? Is there a way to use regex? See my code below:.....................

View 1 Replies

C# - String.Replace Does Not Work For Quote?

Jun 7, 2010

((string)dt.Rows[i][1]).Replace("'", "\'")

I want the result that if any string have quote it change it into slash quote, e.g. John's -> John's

but the above replace function is not working fine. it results like John\'s

but if we change the code to

((string)dt.Rows[i][1]).Replace("'", "'")

View 7 Replies

Replace Null DateTime Value With String?

Mar 8, 2011

I have been facing a problam with replace null datetime Field with String.


My DB filed entrydate not mendetory DateTime is dataType.

Its return Entry date or Null.

When designing Crystal report Enrry date display but when it return null its simply display blankspace.

I want like

Enrry date

View 2 Replies

Mvc Outputting Json With Backslashes ( Escape) Despite Many Attemps To Filter?

Apr 24, 2010

i have an controller that output Json as the results a section of it is here

returnString += string.Format(@"{{""filename"":""{0}"",""line"":[", file.Filename);

what i get returned is this:


i have tried to return with the following methods:

return Json(returnString);
return Json(returnString.Replace("\","");

return Json will serialize my string to a jSon string, this i know but it likes to escape for some reason, how can i get rid of it? for info this is how i call it with jQuery:


View 1 Replies

C# - Replace Part Of Text In A Dynamic String

Oct 27, 2010

Let's take this string has an example:

D:/firstdir/Another One/and 2/bla bla bla/media/reports/Darth_Vader_Report.pdf

I want to cut the first part of the path:

D:/firstdir/Another One/and 2/bla bla bla

And replace it with **../**, and keep the second part of the path (media/reports/Darth_Vader_Report.pdf)

If I knew the length or size of it, I could use the Replace or Substring. But since the first part of the string is dynamic, how can I do this?


After StriplingWarrior question, I realized that I could have explained better.

The objective is to replace everything behind /media. The "media" directory is static, and will always be the decisive part of the path.

View 3 Replies

String.replace() Does Not Work For # (pound) Sign?

Jun 24, 2010

I have a string that I'm pulling from an Excel spreadsheet that is x.firstName

When I pull it in it gets converted to x#FirstName

Fine. So I tried string.replace as shown below and it change my string.

here's my code:

stFormattedColumnName = objDataset1.Tables[0].Columns[i].ToString().ToLower();
//value is x#firstName
//value is still x#firstName

View 3 Replies

String Double Quotes Replace With Empty In C#

Aug 20, 2010

I have string. There are no items to show in this view of the "Personal Documents" then assign to string str variable string str ="There are no items to show in this view of the "Personal Documents" library" Now planning to replace "" and make it to actual string to str object. I tried below, but did not worked

str = str.Replace(@"",string.Empty);

I want str value should be string str ="There are no items to show in this view of the "Personal Documents" library" I need to find this string in another string. While searching into that string. I couldn't found because str contains "".

View 4 Replies

SQL Server :: Replace The String After Comma Starts In MS SQL?

Sep 23, 2010

How to replace the remaining String after the Comma Starts Using SQL Query. Below is the data

"MediaRights, MediaRightsLink, MediaRightsCompanies, MediaRightsTypes"

View 2 Replies

ADO.NET :: How To Replace The Field Names In SQL Query String With Variables

Aug 17, 2010

How can I replace the field names in sql query string with variables like:-

string field1="ID";
string field2="Name";
sql = "Insert into [Sheet1$] ('" + field1 + "','" + field2 + "') values('1','abc')";

I am inserting data into an Excel document which has got nearly 100 columns.

I am inserting data using OLEDB as follows:-

System.Data.OleDb.OleDbConnection MyConnection ;
System.Data.OleDb.OleDbCommand myCommand = new System.Data.OleDb.OleDbCommand();
string sql = null;
MyConnection = new System.Data.OleDb.OleDbConnection(connectionstring);
myCommand.Connection = MyConnection;
sql = "Insert into [Sheet1$] (ID,Name) values('1','abc')";
myCommand.CommandText = sql;

I want to specify the field names at runtime as mentioned above - sql = "Insert into [Sheet1$] ('" + field1 + "','" + field2 + "') values('1','abc')"; When I try this I am getting error.

View 12 Replies

SQL Server :: How To Replace Specific String Regex With Blank

Jan 11, 2011

In my table below string are present which I have to replace *@*$*86$*$ with blank, how can I do? Here bold can be 0-99, in any row.

xOsyH *@*$*86$*$

M. V. *@*$*81$*$ .

View 8 Replies

Web Forms :: FormView Replace Empty String In Textbox Before Insert?

Nov 4, 2010

How can I replace empty space in textbox with a dash (-) before form values are inserted?


I also tried using the datasource's Inserting method but neither works.

View 3 Replies

C# - Remove Extra Spaces And Many Tags Using String.Replace() Method?

Dec 11, 2010

I have a long string containing the ,<p> </p> and <br>. I want to clean my string from all these tags and spaces. How it can be done with String.Replace() method. I am doing separately right now, it is working but is there a way to do it at once, without replace() method.

String.Replace(" ","").Replace("<p>","").Replace("<br>","")

It is giving me clean code but I am looking for a general solution, means if I am having more tags (10 to 20) to filter then how to do it efficiently.

View 5 Replies

Copyrights 2005-15, All rights reserved