Saturday, 21 May 2022

Chapter 23 // Exercise 6 - Principles & Practice Using C++

In this exercise I am using Visual Studio 2019 and a modified version of the std_lib_facilities header found here.

Chapter 23 // Exercise 6

Write a program that finds dates in a text file. Write out each line containing at least one date in the format line-number: line. Start with a regular expression for a simple format, e.g., 12/24/2000, and test the program with that. Then, add more formats.


First I copied the text from this page: 
https://help.scribesoft.com/scribe/en/sol/general/datetime.htm into a text file for testing and used https://regex101.com/ to help me create the right patterns.

After that I ended up with 5 different patterns to test various date formats including ISO. I didn't add validation to the patterns as I feel validation should be done once you have the strings, regex is just for searching.

No comments:

Post a Comment