Split a Delimiters from String?

Dear Team,

i tried to split a delimiters from string . I’ve created the lot number and i need to split this lot number below the example.

Lot Number:

Lot Number: AB-100100001-01233-12

Expected String:
AB, 10010001, 01233-12

How to get it this format in my source string.

Kindly help me on this.

Hi @Isai,
you can split by choosing a delimiter in C# command [yourstring.Split(’-’)], but this will apply to every segment in your string, if you need to leave some of them together, then you need to decide your rule i.e. logic, in your example you need the last two to stay together so you need to code this in your loop after splitting every thing in list variable, alternatively change its symbol to a different than what you splitting your string by.


Dear Baeisa,

thanks your help and quick response. i found the solution in using split with delimiters in array.

string[] tmpSplitLotNo = tmpLotNo.Text.Split(new[] { ‘-’ }, 3);

1 Like