interface SearchAndReplaceRegExp {
    search: string | RegExp;
    replace: string;
    test?: ((obj: SearchAndReplaceRegExp) => boolean);
}

Properties

Properties

search: string | RegExp

The search value to test for

Can be a normal string (converted to a case-sensitive literal) or a valid regular expression as a string, or an actual RegExp object

["find this string", "/some string*/ig"]
replace: string

The replacement string/value to use when search is found

This can be a literal string like 'replace with this, an empty string to remove the search value (''), or a special regex value

See replacement here for more information: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace

test?: ((obj: SearchAndReplaceRegExp) => boolean)

An optional function to execute before running this search-and-replace that decides if it should run at all