function toRegex(search, options) {
	const { caseSensitive = false, wholeWord = false, regExp = false } = options;

	let flags = caseSensitive ? "gm" : "gim";
	let regexString = regExp ? search : escapeStringRegexp(search);

	if (wholeWord) {
		const wordBoundary = "\\b";
		regexString = `${wordBoundary}${regexString}${wordBoundary}`;
	}

	try {
		return new RegExp(regexString, flags);
	} catch (error) {
		const [, message] = error.message.split(/:(.*)/);
		$resultOverview.classList.add("error");
		$resultOverview.textContent = strings["invalid regex"].replace(
			"{message}",
			message || error.message,
		);
		return null;
	}
}
Converts a search string and options into a regular expression.

@param {string} search - The search string.
@param {object} options - The search options.
@param {boolean} [options.caseSensitive=false] - Whether the search is case-sensitive.
@param {boolean} [options.wholeWord=false] - Whether to match whole words only.
@param {boolean} [options.regExp=false] - Whether the search string is a regular expression.
@returns {RegExp} - The regular expression created from the search string and options.