object RegexMatch {
def main(args: Array[String]): Unit = {
// Declare the regex pattern
val pattern = "^htt+p$".r
// Test strings
val testStrings = List("http", "htttp", "httttp", "httpp", "htp")
// Check matches
for (test <- testStrings) {
val matches = pattern.matches(test)
println(s"""Matches "$test": $matches""")
}
}
}
// Matches "httpp": True or false, depending on how matches() method works
/*
run:
Matches "http": true
Matches "htttp": true
Matches "httttp": true
Matches "httpp": false
Matches "htp": false
*/