around()

Gets the substrings around a specific target.

This function is valid in v2.10.0 to v2.17.1. This function has been downloaded 14 times.

Parameters

{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

{Array}
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.