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
- Convert the string to an array of bytes
- Remove any trailing spaces
- Use find_last_index on the array to find the last embedded space.
- Use substr() to select the last word in the orginal string.
- Use $sscanf to convert that last word to a value.