Handle number format exception

Report a typo

Imagine you implement a web service to pay for video games. There is a text field where a user inputs their card number. A card number is a string like "AAAA AAAA AAAA AAAA", where A is any digit. Please note that a correct card number contains three spaces as in the template. Complete the function that receives a card number as a string and returns the card number as a Long or produces any exception when the card number is incorrect.

Tip: You may use regular expressions to solve this task quickly. You can read about them here.

Sample Input 1:

1234 5678 9012 3456

Sample Output 1:

1234567890123456
Write a program in Kotlin
fun parseCardNumber(cardNumber: String): Long {
// TODO
}
___

Create a free account to access the full topic