Extracting a number from a string in system verilog

Thanks for your answer.

I think my example was too simple. In my case, I do not know the exact string but I’m sure that the pattern “packet size is XB” will be present.