voca icon indicating copy to clipboard operation
voca copied to clipboard

keepAfter, keepBefore, keepBetween, keepChars

Open okabak123 opened this issue 2 years ago • 0 comments

Hi, this is a feature suggestion to this awesome library.

The suggested functions are as follows:

  • keepAfter(text, after_string, instance_num*)
  • keepBefore(text, before_string, instance_num*)
  • keepBetween(text, keep_start, keep_end)
  • keepChars(text, keep_string)

*optional arguments

These are inspired by a program called EasyMorph. And for more info I'll link to their documentation.

keepAfter

This function returns characters after the first occurrence of after_string in text, if found. If after_string is not found within text and "empty" value is returned.

keepAfter('a/b/c/d', 'b') //Returns '/c/d'

More info

keepBefore

This function returns characters before the first occurrence of before_string in text, if found. If before_string is not found within text and "empty" value is returned.

keepBefore('5pm', 'pm') //Returns '5'

More info

keepBetween

This function returns the characters between the first occurrence of keep_start and the first occurrence of keep_end in text.

keepBetween('Mary Joe Smith', 'Mary ', ' Smith') //Returns 'Joe'

More info

keepChars

This function keeps only the characters given in keep_string and removes the others from text.

keepChars('a1b2c3', 'abc') //Returns 'abc'

More info

okabak123 avatar Feb 22 '23 11:02 okabak123