I’m trying to split a string by group defined through a regex using the Object Match like this :
if(match.Success)
{
foreach (Group group in match.Groups)
{
foreach(Capture capture in group.Captures)
{
//...
}
}
}
The strings I’m supposed to match are formed like this : Begin or no with “, any caracter any number of time (including “, \r, \n etc.), If begin with ” end with ” too, followed by ; then any caracter any number of time, another;, to finish at least once a mix of space and numbers.
Im using this regexp :
("?[.|\n|\r|\r\n]*"?);(.*);([\d| ]*)(;([\d| ]*))*
I’d like to have the first group which is a string with any char,the second group : string which is only text/number, the third group is always here and is a mix of spaces and numbers and if there are more groups of spaces and number, get them in the group 4,5 6 etc.
An exemple of string i have to match :
“VIS METAUX TETE CYLINDRIQUE FENDUE EN ACIER ZINGUE DIAMETRE
M10”;Longueur 60mm;0046 10 30“Vis à métaux à tête cylindrique fendue. Norme:
DIN 84”;Diamètre 3 mm. Longueur 16 mm;0046 3 16“Tournevis Torx sur monture : 10, 15, 20, 25, 30, 40”;;0613 434
10;0613 434 10;0613 434 20
This doesn’t work at all, the group I match are rarely good and I don’t get how i can do that.
This will only work if you can get each “line” as a separate string, but rather than trying to split, I’d use a regular expression to match each field:
The regular expression matches “a load of non-quote characters with a quote before and after it OR a load of non-semicolon characters with a semicolon or start/end of string before and after it)