Challenge: Searching a String
Explore how to find and extract the first three-letter word consisting entirely of lowercase letters from a given string in Scala. This lesson helps you practice string search and pattern matching to enhance your Scala string handling skills.
We'll cover the following...
Problem Statement
You are given a string and you have to find the first three-letter word in that string. The only condition is that the word must consist of all lower-case letters.
Input
The input is the variable stringToFindExpression in which the string to be searched is stored.
stringToFindExpressionhas already been declared for you.
Output
The output will be the value assigned to match1.
Sample Input
"The car is red."
Sample Output
"car"
Test Yourself
Write your code in the given area. Try the exercise by yourself first, but if you get stuck, the solution has been provided. Good luck!
Let’s go over the solution review in the next lesson.