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.7k 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
- 554,122
- 78
- 1,158
- 1,373
-
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
8
No, you don't need to use a regular expression:
string[] values = input.Split('#');

Jon Skeet
- 1,421,763
- 867
- 9,128
- 9,194
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