before()

Finds the substring before a specific target.

This function is valid in v2.10.0 to v2.24.3. This function has been downloaded 62 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

{string|null}
Returns the string found before target. If target was not found or the specified occurrence (opt_occurrence) of target was not found, null will be returned.

Required Function

This function directly requires the following function which is included automatically:

  • around()
    Gets the substrings around a specific target.

Requiring Function

This function is directly required by the following function:

  • around()
    Gets the substrings around a specific target.