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
Similar Messages:
Sep 27, 2010
"something here [tagQuote=Name of Author]bla bla bla[/tagQuote] something here"And now I want to replace all the whitespace character in quote attribute with "%#%#%#%".So I want to have: [tagQuote=Name%#%#%#%of%#%#%#%Author]bla bla bla[/tagQuote]So remove all of the whitespaces between "[tagQuote=" and "]...[/tagQuote]"
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
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
Jan 22, 2011
I am writing value to a textbox from handler(ashx) file. But the problem is that when the value contains double quote or single quote the textbox only shows the value before that quote and omits the the string after that quote.
For eg Value is: Hi "there
The textbox shows: Hi
View 1 Replies
Mar 1, 2011
I want to write a Regex in DataAnnotations that can unmatch a input string containing not paired double quote " ie. check if zero or a paired double quote allowed in a input string.
matched case:
abcde
"abcde"
abc"d"e
unmatched case:
"abc"de"
"abcde
abc"de
abcde"
MY EXISTING CODE FYR:
using System.ComponentModel.DataAnnotations;
using Microsoft.Web.DynamicData;
namespace EDMModel
{
[MetadataType(typeof(DETAIL_MetaData)), ScaffoldTable(true)]
public partial class DETAIL{}
public class DETAIL_MetaData
{
[Required, RegularExpression(@"[^~`!@#%&()={}|:;'<>,./+?*^$]*", ErrorMessage = "Unsupported Character detected"), StringLength(20), Display(Order = 21)]
public object NAME1 { get; set; }
View 5 Replies
Jan 11, 2010
my table i have a column named [Name] nvarchar(255)[Name] can be a string witch can have some diacritics like "Ăă, Ââ, Îî, Țț, Șș"If i am using this, it returns for word "Antichități" the string "Antichitați"
[Code]....
But if i am trying to replace "ț" with "t", it doesn't work
[Code]....
The result is still "Antichități"How can i resolve this issue?
View 3 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
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
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
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
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