I want to read file if the following pattern.
Here is
file1.text
Abc,192.168.99.4
Eyo,192.168.8.16,3370
Opa,4447
Ctc,192.168.66.2,5507
Here is my code that is working for single , . Var3 is not displaying any value.I am putting
or operation between two and three values regular expresion.
if(EOF == fscanf(mf," %[^,],%s,%s | %[^,], %[^,] %[^,],%s,%s,%s", var1,var2,var3)){
printf("var2=%s\n",var2);
printf(" var1=%s\n",var1);
printf(" var3=%s\n",var3);
}
The code is producing output
Var2=Abc
Var1=192.168.99.4
Var3=
Var2=Eyo
Var1=192.168.8.16,3370
Var3=
Var2=Opa
Var1=4447
Var3=
Var2=Ctc
Var1=192.168.66.2,5507
Var3=
What I have tried:
How to split into two comma separated into 3 values ?