The Regex error probably shouldn't be propagated. If it fails, that's a bug in your code and a panic is more appropriate, IMO. The caller can't fix anything in that case (much less an end user).
But honestly I'd just avoid Regex for this use case, in turn avoiding both of those issues.[1]
That's API library for Client/Server, so it should not panic itself but return the result.
I'm not sure about the regex too, just can't find the native replacement. Of course I can build random token using local pattern, but this operation is more expensive so looking for rand API.
There is literally nothing a user of the library can do about a hard-coded regex failing to parse. It would be a bug that only you, the library maintainer, can fix. If it works once,[1] it will never fail (barring a breaking change by the regex crate which is quite unlikely and wouldn't be your fault).[2]Here's more reading on the topic (by the regex author incidentally).
A replacement for the regex as used in your OP is demonstrated in my "avoid Regex" playground.
The build function in your OP wasn't building any random tokens. What are you actually trying to do? I'm still not clear on what you're inquiring about.