Is your feature request related to a problem? Please describe.
I want to trim multiple trailing strings of the input, which is now not supported
Describe the solution you'd like
Overload trimTrailing
options to accept array of strings, and trim them in sequence.
options = {
trimTrailing: ['a', 'ab', 'c'],
}
Example
isPalindrome('aaaaabacccccababa', {trimTrailing: ['a', 'ab', 'c']}); // true
// after trim a: 'abacccccababa'
// after trim ab: 'abacccccaba'
// after trim c: 'abacaba'
Alternatives
This is a little bit advanced, but I may want to have mode support for continually trim when any of the string in the array can be matched.
Imagine that a trimming step can make another trailing string happened.
Example:
isPalindrome('abccccccabc', {trimTrailing: ['abc', 'c']})
// Check for trailing 'abc' in 'abccccccabc' but found no occur
// After trim 'c': abcabc
// The string after trim 'c' introduce a trailing 'abc'
Now with this mode we will have something like:
isPalindrome('abccccccabc', {trimTrailing: ['abc', 'c'], trimTrailingCon: true})
// Check for trailing 'abc' in 'abccccccabc' but not found
// After trim 'c': abcabc
// Again, check for trailing 'abc' in 'abcabc' and found, then trim: 'abc'
// Again, check for trailing 'abc' in 'abcabc' and found nothing
// All of the trailing string are not found, so we can stop the operation
// Output: 'abc'