I have the code to check a text file line-by-line but I am unsure how to check for a specific format. If the text file is in the following format print out the content, otherwise dipslay a message saying “File is not correct.”
The first line of the should start with an S, and every line consists of any upper-case, followed by a colon, than any letter, number or e.
You can use regular expressions to easily validate the format:
The regex is: First
SorVrespectively, then:, and then any character between A-Z ot 0 or 1 or e.The
?means 0 or one repeats, so[A-Z01e]?[A-Z01e]?[A-Z01e]means 1-3 characters, each A-Z or 0 or 1 or e.