jstests/aggregation/expressions/regex.js
/**
 * This function validates the output against $regexFind, $regexFindAll and $regexMatch
 * expressions.
 */
This function validates the output against $regexFind, $regexFindAll and $regexMatch
expressions.
This function validates the output against $regexFind $regexFindAll and $regexMatch expressions .
function testRegexFindAgg(inputObj, expectedOutputForFindAll) {
    testRegex("$regexFindAll", inputObj, expectedOutputForFindAll);
    const expectedOutputForFind = expectedOutputForFindAll.map(
        (element) => ({matches: element.matches.length == 0 ? null : element.matches[0]}));
    testRegex("$regexFind", inputObj, expectedOutputForFind);
    const expectedOutputForMatch =
        expectedOutputForFindAll.map((element) => ({matches: element.matches.length != 0}));
    testRegex("$regexMatch", inputObj, expectedOutputForMatch);
}
function testRegexFindAgg ( inputObj , expectedOutputForFindAll ) { testRegex ( "$regexFindAll" , inputObj , expectedOutputForFindAll ) ; const expectedOutputForFind = expectedOutputForFindAll . map ( ( element ) => ( { matches : element . matches . length == 0 ? null : element . matches [ 0 ] } ) ) ; testRegex ( "$regexFind" , inputObj , expectedOutputForFind ) ; const expectedOutputForMatch = expectedOutputForFindAll . map ( ( element ) => ( { matches : element . matches . length != 0 } ) ) ; testRegex ( "$regexMatch" , inputObj , expectedOutputForMatch ) ; }
This function validates the output against $regexFind, $regexFindAll and $regexMatch
 expressions.
This function validates the output against $regexFind $regexFindAll and $regexMatch expressions .
// For each of the output document, get first element from "matches" array. This will // convert 'regexFindAll' output to 'regexFind' output. // For each of the output document, if there is at least one element in the array, then // there is a match.