Comment Rewrite Rules

The “comment rewrite rules” use pattern matching to reformulate the column to match a comment used by NAPA.

This can be used to convert comments like:

80 Amp => w/ 80 Amp Alternator

The matching works in this order:

  1. Check for a comment match first with no changes.
  2. Apply all replacement rules and check result.
  3. For each rewrite rule:
        a. Apply rule to comment without replacement and check.
        b. Apply rule to comment with replacements and check.

Example:

CommentRewriteScreen.png

Special Date Handling

The following pattern should handle most date formats:

^From\s0?(?P<p1>(\d\d?/)?\d\d?/(19|20)?\d\d)$

This rewrite rule will work for dates in the format m/d/y or m/y. Year can be 2 or 4 digits. If the value is a date, it is best to capture the full date and not the individual values. Resulting dates are formatted without leading 0s on month or day and with 2 digit years to correspond with NAPA’s most prevalent date formatting.

There are times when you might want to map a “Before”, “After” or “Thru” date differently because NAPA uses primarily “From” and “To” dates. Assuming a date placeholder of <p0>, to increment a date, use {++0} in the rewrite string. To decrement, use {--p0}. For m/d/y dates, the increment and decrement operators work on the day. For m/y, they work on the month.

Examples for {--p0}:

1/00 (or 1/2000) => 12/99  
03/1999 => 2/99  
1/1/2000 => 12/31/99  
12/10/1999 => 12/9/99

Examples for {++p0}:

12/1999 => 1/00  
1/2000 => 2/00  
12/31/1999 => 1/1/00

Do not capture individual values for month, day and year if using date arithmetic. The value will be treated as numbers instead of dates.

Examples for {--p0}/{p1} (bad, don’t do this!)

2/00 => 1/00
1/00 => -1/00

As shown below:

DateMatching.png

Another example pattern for this method would be:

^After\s0?(?P<p1>\d\d?/(19|20)\d\d)$

From {++p1}
Revised: 2013-12-05