Extracting a number from a string in system verilog

In reply to rubendah:

It is best to use a regular expression for this. See System veilog Regular expressions | Verification Academy

Otherwise you can the following steps

  1. Convert the string to an array of bytes
  2. Remove any trailing spaces
  3. Use find_last_index on the array to find the last embedded space.
  4. Use substr() to select the last word in the orginal string.
  5. Use $sscanf to convert that last word to a value.