Remove any trailing whitespace, stop-words (the/a/an/of/…) and
trailing punctuation (including any pre-existing ellipsis). Implemented
imperatively to avoid super-linear regex backtracking on the
(?:\s+stop-word)+$ pattern flagged by security/detect-unsafe-regex.
Parameters
input: string
Pre-clipped string to clean up
Returns string
Cleaned string with no trailing stop-words or punctuation
Remove any trailing whitespace, stop-words (the/a/an/of/…) and trailing punctuation (including any pre-existing ellipsis). Implemented imperatively to avoid super-linear regex backtracking on the
(?:\s+stop-word)+$pattern flagged bysecurity/detect-unsafe-regex.