5

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

D Stanley
  • 144,385
  • 11
  • 166
  • 231
dovydas juraska
  • 277
  • 2
  • 5
  • 11

4 Answers4

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
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
8

Use the string.Split() method.

string[] myArray = input.Split('#');
Dave Zych
  • 21,041
  • 7
  • 51
  • 65
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