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
Asked
Active
Viewed 1.5k times
4 Answers
11
You can just use String.Split:
string input = "27173316#sometext.balbalblabba#4849489#text#text2#number";
string[] values = input.Split('#');
Reed Copsey
- 539,124
- 75
- 1,126
- 1,354
-
damn, so easy. thanks a bunch! – dovydas juraska Nov 19 '12 at 19:59
-
3@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. – Victor Zakharov Nov 19 '12 at 20:00
-
@dovydasjuraska If this answer worked, please mark it as accepted. – Ryan Gates Nov 19 '12 at 21:12
8
No, you don't need to use a regular expression:
string[] values = input.Split('#');
Jon Skeet
- 1,335,956
- 823
- 8,931
- 9,049
0
You can get the original string and your Splitting character and ca split the string...
string origInput = "yout values with # and other sign"
char[] splitCode = new char[]{'#'}; //if you have more then one split sign you can add here
string[] output = origInput.Split(splitCode,StringSplitOptions.None);
Vish Soni
- 43
- 1
- 7