Regex not working like regex101


I’m trying to regex some cookie values, but the n8n function node does not work like regex so I’m a little bit confused:

String would be:
{ cookies: [ { name: 'XX_234_132', value: 'FER_JKO_gvbhnjmk3223gbhnj', domain: '' } ] }

To get the value without the quotes I normally use the following regex:
(?<=value: \')(.*)(?=\', domain)

Function node got something like this:
var cookieValue = outputRaw.match(/(value...)(.*)(...domain.*)/)

Using regex101, this extracts the right part but in n8n it results in an variable with null content.

Am I doing something wrong?

Found a solution, but I’m still wondering why this is not working like reg101

This works:


I used the example you provided in regex101 and did a generate code in javascript and got:

const regex = /(?<=value: \')(.*)(?=\', domain)/gm;
const str = `{ cookies: [ { name: 'XX_234_132', value: 'FER_JKO_gvbhnjmk3223gbhnj', domain: '' } ] }`;
let m;

while ((m = regex.exec(str)) !== null) {
    // This is necessary to avoid infinite loops with zero-width matches
    if (m.index === regex.lastIndex) {
    // The result can be accessed through the `m`-variable.
    m.forEach((match, groupIndex) => {
        console.log(`Found match, group ${groupIndex}: ${match}`);