Test, validate and match regular expressions
This regex matches lowercase letter/hyphen sequences followed by either exactly three digits or no digits (group 1), optionally capturing one final digit at the end of a line (group 2). Used with global and multiline flags, it processes text line by line; replacing matches with the first capture group effectively strips a trailing digit from slug-like strings (e.g., 'field1' -> 'field'), while 3-digit suffixes are kept intact.