[Solved] Splitting of words Dynamically in c# [duplicate]


You can go with regex in here like this:

Regex rgxData = new Regex("([0-9 ]+)([a-zA-Z]+)");
Match mData = rgxData.Match(input);

string sr = mData.Groups[1].Value.Trim();
string quota = mData.Groups[2].Value.Trim();

This will result in:

input = "153 81 2612GEN";

  • SR: 153 81 2612
  • Quota: GEN

input = "153 81 1 1 1 1 1 1 ABCDE";

  • SR: 153 81 1 1 1 1 1 1
  • Quota: ABCDE

input = "123 AB";

  • SR: 123
  • Quota: AB

6

solved Splitting of words Dynamically in c# [duplicate]