C# split string after each # symbol
14,321
Solution 1
You can just use String.Split:
string input = "27173316#sometext.balbalblabba#4849489#text#text2#number";
string[] values = input.Split('#');
Solution 2
No, you don't need to use a regular expression:
string[] values = input.Split('#');
Solution 3
Use the string.Split()
method.
string[] myArray = input.Split('#');
Author by
dovydas juraska
Updated on June 13, 2022Comments
-
dovydas juraska almost 2 years
i was wondering is there's only one way ( regex ) to split string after each # symbol here's how looks result, which i want to split in string variables 27173316#sometext.balbalblabba#4849489#text#text2#number I want to past each value before # in string variable or array
-
dovydas juraska over 11 yearsdamn, so easy. thanks a bunch!
-
Victor Zakharov over 11 years@NikolaD-Nick: The funny thing is how votes get distributed by reputation, i.e. that who has the most gets the most upvotes, even though all answers are effectively the same.
-
Ryan Gates over 11 years@dovydasjuraska If this answer worked, please mark it as accepted.