Jump to content

Splitting...

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Chan

Chan

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 204 posts
In C# is there a way to split by line-break or any other character for that matter?

I need to take string:

1,2,9,10,39,14

and split by the ","

#2
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
If you have a string like this:
string myString = "1,2,9,10,39,14";
And want each one of them (1, 2, 9, 10, 39, 14) to become strings in an array, you can do something like this:
string[] myArray = myString.Split(',');
In this example the ',' is of course our delimeter.

#3
McMillan0520

McMillan0520

    Newbie

  • Members
  • Pip
  • 4 posts
What if you want to split by a string? Because i have this problem: i want to split a string by the string "//DATA//", but i Hate RegEx. is there any other way?

#4
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Regex would be your best choice and you don't need a full-blown regex expression to split by string:

string[] myArray = Regex.Split(myString,"//DATA//");