Rings of Power

Report a typo

Using special characters, create a regex instance named regex that matches all the strings below:

"20 rings", "9 rings", "7 rings", "3 rings", "1 ring".

Tip: Your task is to make a regex that suits the situation best. Don't try to write a universal pattern: use the characters . and ?.


Where there's life there's hope.
― J.R.R. Tolkien

Sample Input 1:

9 rings

Sample Output 1:

true

Sample Input 2:

1 ring

Sample Output 2:

true

Sample Input 3:

many different rings

Sample Output 3:

false

Sample Input 4:

100 rings

Sample Output 4:

false
Write a program in Kotlin
val regex = TODO()
___

Create a free account to access the full topic