Give me your token

Report a typo

You need to extract the server name and token from a URI in the format http://SERVER_NAME/?token=SOME_SYMBOLS. The server name and token can contain alphanumeric characters. You want to display the extracted information as s"Server: $SERVER_NAME and token: $TOKEN".

If you can't parse a string, your function must return "Error".

Sample Input 1:

http://localhost/?token=1b2a3r

Sample Output 1:

Server: localhost and token: 1b2a3r
Write a program in Scala 3
def parseServerAndToken(uri: String): String =
??? // Write your code here
___

Create a free account to access the full topic