Skip to content

keepAfter, keepBefore, keepBetween, keepChars #62

@okabak123

Description

@okabak123

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions