What you are really asking is, how do you properly put the backslash into the regex. That is a very good question that you need to know the answer to:
First, in order to specify a literal backslash in a regex, you must escape it with a backslash. : \ - so far so good.
Second, you are putting that in a string, which also uses a backslash as an escape. So the compiler is quite possibly converting that to just one backslash.
In order to have it make it into the regex as two backslashes, you may have to escape them both. So it becomes \\ - yes, 4 backslashes.
That said, the smart thing to do is accept only those characters that you expect: /prefix/([-a-zA-Z0-9]*)
And if you put the two together, you can be assured that the application is returning valid values in the responses: