How to read comma separated string through fscanf

Hi All,
My_file.csv
Addr,cmdtype,burst_type,transaction_gap
5cab45,write,Wrap,random
11bbc,read,Incr,random

I want to read above .CSV file in systemverilog or uvm but problem is that When I am reading string through $fscanf function then I am getting whole string in one veritable .my sv code is as below,


module ready_csv();
initial begin
  int addr;
string Trans_mode,cmd_type, transaction_gap,S1;
int fd;
fd= $fopen("My_file.csv","r");
  $fscanf(fd,"%0s",S1);
  $fscanf(fd,"%0h,%0s,%0s,%0s",addr,Trans_mode,cmd_type, transaction_gap);
  $display("addr=%0h, Trans_mode=%0s,cmd_type=%0s, transaction_gap=%0s",addr,Trans_mode,cmd_type, transaction_gap);
end
endmodule

Result :
addr =5cab45, Trans_mode=write,Incr,random,cmd_type= , transaction_gap=
But I want to read as per below print,
addr =5cab45, Trans_mode=write,cmd_type=Incr , transaction_gap=random

Kindly help me .

Regards,
Prashant

In reply to Prashant Soni:

Verilog’s $fscanf is very limited when it comes to strings.

You’re going to have to parse the string yourself, or see Use of regular expression for string comparison | Verification Academy

In reply to dave_59:

Thank you for your response,
How uvm_re_match function will useful for me? could describe it in detail?

In reply to Prashant Soni:

Actually, the str.match() and str.backref() are extensions to SystemVerilog that will help. Check your tools manual.