a1jit Posted November 4, 2005 Posted November 4, 2005 Hi Guys, I was just thinking wheather how do i do this I want to do some replace operation, for an example, i want to replace the "\r\n" string with " " So lets say i have this, it works properly. string str = "test\r\n" if i use a replace function here, i get only "test" but lets say i have this string str = "test\r\n\r\n" how do i actually write a small function that find any combination of \r\n and replaces it with " " ? like if the string is "test\r\n\r\n" It should give me "test" Any idea? Quote
Administrators PlausiblyDamp Posted November 4, 2005 Administrators Posted November 4, 2005 Either string.Replace() or RegEx.Replace() should do what you are after. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
a1jit Posted November 5, 2005 Author Posted November 5, 2005 Actually i have tried with the str.replace() function.. I doesnt replace if str is below. string str = "test\r\n\r\n" str.replace("\r\n","") still gives me "test\r\n\r\n" Quote
Leaders snarfblam Posted November 5, 2005 Leaders Posted November 5, 2005 Could you post the code? Quote [sIGPIC]e[/sIGPIC]
Administrators PlausiblyDamp Posted November 5, 2005 Administrators Posted November 5, 2005 The string functions do not change the string, they return a new string so have you tried string str = "test\r\n\r\n"; str = str.replace("\r\n","") ; Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.