There are lots of ways to do that. It's important to know though, whether it will always be the last character in the url. Is it a pattern, in other words.
If you know it will always be the last char in the string, you can just grab it.
$lastChar = substr(request()->headers->get('referer'), -1);
You can also use regex and actually grab digits from the string. That might work, but again, it depends on if there is a pattern to look for. There could be a number in 2 different places in the url or something.