hi i am trying to split a string using regx. How do i get the nth occurrence of a pattern so i could assign it to a string?
var myString = "1.2.300.4";
var pattern = new Regex(@"([0-9]+)");
var major = pattern.Occurrence(1); //first occurrence
var minor = pattern.Occurrence(2) //second occurrence
var build = pattern.Occurrence(3) //third occurrence
var revision = pattern.Occurrence(4) // forth occurrence
something to that effect but in regex.
is there a way to choose the occurrence in the regex pattern itself? eg;
var major = new Regex(@"([0-9]+)$1");
var minor = new Regex(@"([0-9]+)$2");
var build = new Regex(@"([0-9]+)$3");
var revision = new Regex(@"([0-9]+)$4");