S Steve Aug 3, 2007 #1 I'm getting a string such as name1\r\nname2 how can I remove the \r\n and just have the string as name1 name2?
I'm getting a string such as name1\r\nname2 how can I remove the \r\n and just have the string as name1 name2?
F Fred Chateau Aug 3, 2007 #2 If you remove the new line characters. you're not going to get: name1 name2 You'll get: name1 name2 Is that what you want? -- Regards, Fred Chateau fchateauAtComcastDotNet I'm getting a string such as name1\r\nname2 how can I remove the \r\n and just have the string as name1 name2?
If you remove the new line characters. you're not going to get: name1 name2 You'll get: name1 name2 Is that what you want? -- Regards, Fred Chateau fchateauAtComcastDotNet I'm getting a string such as name1\r\nname2 how can I remove the \r\n and just have the string as name1 name2?
S Steve Aug 3, 2007 #3 well, the thing is I need to pass each name into a method so I can get their information. here is what I have. I have a textbox that a user can enter names in, its a multiline textbox and they can enter the names in 2 ways, 1) all on one line and let the textbox wrap them -- name1,name2,name3,name4,name5, name6 and so on 2) or like this name1 name2 name3 and so on if they enter like #2 I need to take each name one by one and get their information.
well, the thing is I need to pass each name into a method so I can get their information. here is what I have. I have a textbox that a user can enter names in, its a multiline textbox and they can enter the names in 2 ways, 1) all on one line and let the textbox wrap them -- name1,name2,name3,name4,name5, name6 and so on 2) or like this name1 name2 name3 and so on if they enter like #2 I need to take each name one by one and get their information.
F Fred Chateau Aug 3, 2007 #4 Either way, I would use the Regex.Split() method in System.Text.RegularExpressions.
J Jesse Houwing Aug 3, 2007 #5 Hello Steve, You can use the split function of Strign to do this. string[] names = inputString.Split(new char[]{',','\r','\n'}, StringSplitOptions.RemoveEmptyEntries) Jesse
Hello Steve, You can use the split function of Strign to do this. string[] names = inputString.Split(new char[]{',','\r','\n'}, StringSplitOptions.RemoveEmptyEntries) Jesse
S Steve Aug 3, 2007 #6 OK, I'll have to take a look at that due to I never used it. do you have an example?
A Alexey Smirnov Aug 3, 2007 #7 OK, I'll have to take a look at that due to I never used it. do you have an example? Click to expand... string input = "name1\r\nname2"; foreach(string s in Regex.Split(input,"\r\n")) { other_method(s); } More about Regex.Split http://msdn2.microsoft.com/en-us/library/system.text.regularexpressions.regex.split.aspx Hope this helps
OK, I'll have to take a look at that due to I never used it. do you have an example? Click to expand... string input = "name1\r\nname2"; foreach(string s in Regex.Split(input,"\r\n")) { other_method(s); } More about Regex.Split http://msdn2.microsoft.com/en-us/library/system.text.regularexpressions.regex.split.aspx Hope this helps