exercism-elixir/date-parser/HINTS.md
2022-02-03 15:18:36 -04:00

2.6 KiB

Hints

General

1. Match the day, month, and year from a date

  • Remember to return a string representing the regular expression pattern.
  • Review how to create character classes or use shorthand character classes.
  • Review quantifiers.
  • A day is one or two digits.
  • A month is one or two digits.
  • A year is four digits.

2. Match the day of the week and the month of the year

  • Review how to write a pattern to match string literals.
  • Review alternations.
  • Wrap the whole expression in a group.

3. Capture the day, month, and year

  • Review how to write patterns for captures and named captures.
  • Reuse the day/0, month/0, year/0, day_names/0, and month_names/0 functions that you already implemented.

4. Combine the captures to capture the whole date

  • Remember, string interpolation may be used to join strings.
  • Reuse the capture_day/0, capture_month/0, capture_year/0, capture_day_name/0, and capture_month_name/0 functions that you already implemented.

5. Narrow the capture to match only on the date

  • Remembers, anchors help to match the pattern to the whole line.
  • String interpolation may be used in the regular expression sigil syntax.
  • Reuse the capture_numeric_date/0, capture_month_name_date/0, and capture_day_month_name_date/0 functions that you already implemented.