Function beforeMatch

Returns all the text in source that precedes (and does not include) match. If not found, source is returned.

See also: beforeMatch, beforeAfterMatch.

afterMatch(`Hello. There`, `.`); // ' There'
afterMatch(`Hello, there', `,`); // 'Hello, there'

If source is undefined, an error is thrown.

  • Parameters

    • source: string
    • match: string
    • options: Partial<MatchOptions> = {}

    Returns string