function trimAfterFirstMatch(regexp, string)
{
	const index = string.search(regexp)

	if (index >= 0) {
		return string.slice(0, index)
	}

	return string
}
Trims away any characters after the first match of {@code pattern} in {@code candidate},
returning the trimmed version.