around()
Gets the substrings around a specific target.
This function is valid in
v2.10.0 to v2.24.3.
This function has been downloaded 64 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 directly requires the following functions which are included automatically:
-
after()
Finds the substring after a specific target.
-
before()
Finds the substring before a specific target.
-
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.
Requiring Functions
This function is directly required by the following functions:
-
after()
Finds the substring after a specific target.
-
before()
Finds the substring before a specific target.