Escaping Backslashes In String.replace?
Jan 25, 2011
I have an image control with the following string
[URL]
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:
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
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
<b>%THIS CAN BE ANY TEXT%</b>.
[Code]....
View 5 Replies
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:
localhost/Page/A//C
But when the request hits the page, the raw url is:
localhost/Page/A/C
Not sure if this is the culprit, but I do have a Url Rewite regex in place, here's the rule:
<system.webServer>
<rewrite>
<rules>[code]...
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
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
Dec 1, 2010
i have a string and want to remove text up to the last forward slash, e.g
/images/UserThumbnails/22.jpg
Should now be
22.jpg
How do i go about doing this?
View 2 Replies
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
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)", Master.cn))
{
SqlDataReader rdr = cmd.ExecuteReader();
if (rdr.Read())
{
emailBody = rdr[0].ToString();
emailSubj = rdr[1].ToString();
}
rdr.Close();
}
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
Sep 13, 2010
how to change
XXX@YYY.ZZZ into XXX_YYY_ZZZ
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
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
vocation
elation
sage
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
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
Sep 16, 2010
txtPhoneWork.Text.Replace("-","");
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
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
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
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
Mar 8, 2011
I have been facing a problam with replace null datetime Field with String.
Like
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
-----------
07-03-2011
Unavl
12-03-2011
13-03-2011
View 2 Replies
Apr 24, 2010
i have an asp.net 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:
"{"DPI":"66.8213457076566","width":"563.341067","editable":"True","pricecat":"6","numpages":"2","height":"400","page":[{"filename":"999_9_1.jpg","line":[]},{"filename":"999_9_2.jpg","line":[]}]]"
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:
$.ajax({
url:"/Products/LoadArtworkToJSon",
type:"POST",[code]...
View 1 Replies
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?
Update
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
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:
string
stFormattedColumnName = objDataset1.Tables[0].Columns[i].ToString().ToLower();
//value is x#firstName
stFormattedColumnName.Replace('#',
'.');
//value is still x#firstName
View 3 Replies
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
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
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);
MyConnection.Open();
myCommand.Connection = MyConnection;
sql = "Insert into [Sheet1$] (ID,Name) values('1','abc')";
myCommand.CommandText = sql;
myCommand.ExecuteNonQuery();
MyConnection.Close();
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
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
Nov 4, 2010
How can I replace empty space in textbox with a dash (-) before form values are inserted?
[Code]....
I also tried using the datasource's Inserting method but neither works.
View 3 Replies
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