Gets the substrings around a specific target.

This function is valid in v2.10.0 to v2.20.0. This function has been downloaded 22 times.


{string} subject
The string to search.
{string|RegExp} target
The target to find and key off of within subject.
{number=} opt_occurrence Optional, Default:1
The occurrence of target that you want to key off of within subject. If negative, the occurrence will be counted from the end of subject.


Returns an array with two values: the string found before target and the string found after target. If target was not found or the specified occurrence (opt_occurrence) of target was not found, [null, null] will be returned.

Required Functions

This function requires the following functions which are included automatically:

  • modRegExp()
    Creates a new copy of a regular expression with modified flags.
  • quoteRegExp()
    Turn any string into a regular expression that matches the exact string without worrying about encoding the metacharacters yourself.
  • typeOf()
    Either gets the type of a value or adds a constructor registering its custom type name.
  • after()
    Finds the substring after a specific target.
  • before()
    Finds the substring before a specific target.