-3

How can I match this string in c# using regex so it returns 4 groups per line?

1 or more digits|one or more letters|one or more letters|one ore more X-Digit(s)\n

Example:

123|ABC|ABC|X-1;X-12;X-13
123|ABC|ABC|X-1

I've tried this \d+\|(A-Z)\|(A-Z)\|(X-)d+

BobSwanson
  • 423
  • 2
  • 5
  • 18

1 Answers1

2

Why shooting with canons at birds?=! If you could simply use the String.Split method to achieve that

string test = "123|ABC|ABC|X-1;X-12;X-13";

string [] groups = test.Split('|');

it will return an array of elements that were separated by a |

Mong Zhu
  • 23,309
  • 10
  • 44
  • 76