String Manipulation
-
I have a tuff question, and ill give anyone my first born child for an answer. Im reading a comma delimited text file. So i have strings that I read in that look like this, "test", "test2", "test3", well here is my problem. The file gets screwed up from time to time and throws in extra quotes whereever it wants. So I often get this ""test, """"test2"", . Im using the split function with a string array to split the line when i read it in, but i need to know how to remove those damn quotes from the strings. I have tried using the trim function and the replace function to no avail. Any help would be greatly appreciated. Thanks, Ryan
-
I have a tuff question, and ill give anyone my first born child for an answer. Im reading a comma delimited text file. So i have strings that I read in that look like this, "test", "test2", "test3", well here is my problem. The file gets screwed up from time to time and throws in extra quotes whereever it wants. So I often get this ""test, """"test2"", . Im using the split function with a string array to split the line when i read it in, but i need to know how to remove those damn quotes from the strings. I have tried using the trim function and the replace function to no avail. Any help would be greatly appreciated. Thanks, Ryan
Instead of trimming, I would try to find why the extra quotes get in the file. How do you produce the file, how do you read it? Do you have code samples to show?
-
Instead of trimming, I would try to find why the extra quotes get in the file. How do you produce the file, how do you read it? Do you have code samples to show?
Well that is part of the problem. This is an add on to an already released product, and they have no intention of fixing the issue with the current product, some Im stuck with what it gives me.
-
I have a tuff question, and ill give anyone my first born child for an answer. Im reading a comma delimited text file. So i have strings that I read in that look like this, "test", "test2", "test3", well here is my problem. The file gets screwed up from time to time and throws in extra quotes whereever it wants. So I often get this ""test, """"test2"", . Im using the split function with a string array to split the line when i read it in, but i need to know how to remove those damn quotes from the strings. I have tried using the trim function and the replace function to no avail. Any help would be greatly appreciated. Thanks, Ryan
Maybe I'm missing something, but do you need the quotes at all (i.e. do any of the strings contain embedded commas)? If not then why not remove all the quotes first (using Replace), then use Split to break up the line on the commas? If the strings can contain embedded commas then it's harder. You say that it "throws in extra quotes whenever it wants", but then in your example its actually omitted a quote as well (between 'test' and the comma immediately after it). Does this really happen or was this an error in the example? Also, can it really add extra quotes "anywhere" (including in the middle of the text strings), or does it simply replace one quote by one or more quotes? Knowing the exact nature of the problem would help in trying to find a solution. Chris Jobson
-
Maybe I'm missing something, but do you need the quotes at all (i.e. do any of the strings contain embedded commas)? If not then why not remove all the quotes first (using Replace), then use Split to break up the line on the commas? If the strings can contain embedded commas then it's harder. You say that it "throws in extra quotes whenever it wants", but then in your example its actually omitted a quote as well (between 'test' and the comma immediately after it). Does this really happen or was this an error in the example? Also, can it really add extra quotes "anywhere" (including in the middle of the text strings), or does it simply replace one quote by one or more quotes? Knowing the exact nature of the problem would help in trying to find a solution. Chris Jobson
I want to remove all of the quotes, thats my goal. I have also tried using the replace function with both character and string overloads, but it doesnt seem to work, Im fairly new to c# so I apoligize for any newbie questions in advance. I was attempting to do something similar to this, string.replace(", null) or string.replace(char [] {'"'}, null), and I had no luck. If someone could give me directions on how to remove quotes or tick marks from a string my problem would be solved. Thanks for your patience. Ryan
-
I want to remove all of the quotes, thats my goal. I have also tried using the replace function with both character and string overloads, but it doesnt seem to work, Im fairly new to c# so I apoligize for any newbie questions in advance. I was attempting to do something similar to this, string.replace(", null) or string.replace(char [] {'"'}, null), and I had no luck. If someone could give me directions on how to remove quotes or tick marks from a string my problem would be solved. Thanks for your patience. Ryan
String.Replace("\"", null);
-
I have a tuff question, and ill give anyone my first born child for an answer. Im reading a comma delimited text file. So i have strings that I read in that look like this, "test", "test2", "test3", well here is my problem. The file gets screwed up from time to time and throws in extra quotes whereever it wants. So I often get this ""test, """"test2"", . Im using the split function with a string array to split the line when i read it in, but i need to know how to remove those damn quotes from the strings. I have tried using the trim function and the replace function to no avail. Any help would be greatly appreciated. Thanks, Ryan
String.Replace("\"", null);
-
I have a tuff question, and ill give anyone my first born child for an answer. Im reading a comma delimited text file. So i have strings that I read in that look like this, "test", "test2", "test3", well here is my problem. The file gets screwed up from time to time and throws in extra quotes whereever it wants. So I often get this ""test, """"test2"", . Im using the split function with a string array to split the line when i read it in, but i need to know how to remove those damn quotes from the strings. I have tried using the trim function and the replace function to no avail. Any help would be greatly appreciated. Thanks, Ryan
Sounds like a really good time to learn Regex'es.
Shameless Plug - Distributed Database Transactions in .NET using COM+
-
String.Replace("\"", null);
THANKS!!!!!!!!!!!
-
I want to remove all of the quotes, thats my goal. I have also tried using the replace function with both character and string overloads, but it doesnt seem to work, Im fairly new to c# so I apoligize for any newbie questions in advance. I was attempting to do something similar to this, string.replace(", null) or string.replace(char [] {'"'}, null), and I had no luck. If someone could give me directions on how to remove quotes or tick marks from a string my problem would be solved. Thanks for your patience. Ryan
s.Replace("\"", "")
will remove all the double-quote characters in s. Chris Jobson