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
  • 149,601
  • 11
  • 178
  • 240
dovydas juraska
  • 277
  • 2
  • 5
  • 12

4 Answers4

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

Use the string.Split() method.

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