String template and variable extraction

now given an original string, example: abcdefgh, a template rule, example: ab {{}} de {{}} h

where {{}} represents any match, and there may be 0 or more {{}} in a template. It is required to write a function to match the template first. If the original string conforms to the template rules, the variable is extracted. The result of the example is the array

of ["c", fg "].
function (str string, temp string) (bool, []string) {
    //  strtempfalse
    //  abcdefgh  ab{{}}de{{}}h abcdefghi ab{{}}de{{}}hi
    
    // 
}

I"ve thought about it. Either regular or character split, is easy to solve for a variable symbol, but for multiple variable symbols, full-text matching will fail. I"d like to consult

.

is also simple, just convert your custom template into an equivalent regular expression within the method, and then match it.


function tempMatch(str, temp) {
    temp = "^" + temp.replace(/{{}}/g, "(.+?)") + "$";
    let matchs = str.match(temp), result = [];
    for (let i = 1; i< matchs.length; i PP) {
        result.push(matchs[i]);
    }
    return result;
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e8f11b-47003.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e8f11b-47003.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?