Hello team!
Today we will review solution for coding exercises.
Let's start from the first one pin number formatting.
The solution is pretty simple.
Do you remember that in demo for string formatting, I put examples of precision formatting at the bottom.
Here also was an example about floating point number formatting.
Basically, you can control number of places in your floating point number.
And here is the solution.
You are using specifiers to indicate that you want to format floating point number with scale of one.
After that, you can use newline specifier if you wish, and format pin number again to have floating
point number with scale of two, and so on.
Here you can see results in console output.
The second task ask user to enter text and split words.
Hope you successfully learned regular expressions.
Now you understand that you have different ways to implement this task.
You can list all punctuation marks in regular expression.
And you can use Posix basic regular expression Posix was developed by the Institute of Electrical and
Electronics Engineers, mostly to provide backward compatibility with the traditional simple regular
expressions syntax, providing a common standard.
In Posix, we have different character classes and categories here in comments I listed for you Posix
character classes.
In our regular expression, we can use punctuation class and special character for all white spaces.
Let's split our line in case punctuation marks or spaces will be found in the string one time or more
times in a row.
Let me run this program and I will enter any text here with different amount of spaces and punctuation
marks.
Pressing enter and here all words that I entered.
That's all.
Thank you for your attention and see you in the next lesson.
Aethes.