REGEX node to extract URL parameters

Hi

I have three issues,all related to my attempts to extract query parameters from a URL string field in a table.

Firslty i used split nodes to seperate each element using & as delimeter. However, this would work as required as the URL structure is not consist (ie the elements are not in the same space for all URLs in the file). Therefore i had utm_campaign in the same column as utm_source for example.

Then i used string to URI node followed by Extract URI Info node to get just the query parameters element. THis worked, but im still having an issue seperating each element out of the query parameter field!

The i tried reg ex node, but for some reason the reg ex wont work depsite my checking online testers and getting corrent result.

Ive tried some example javascripts, but cant get these working, and came across a ruby solution which looks ike it should work, but cant load the extension!

So the issues i need help with;

1 - Loading binary file extension

2 - Regex to extract each parameter, so device, keyword, utm_adgroup etc.

3 - How does one use javascrip like below in javascript node and get it working?!

 

window.getSearch = function(variable) {
  var parsedSearch;
  parsedSearch = window.parsedSearch || (function() {
    var match, re, ret;
    re = /\??(.*?)=([^\&]*)&?/gi;
    ret = {};
    while (match = re.exec(document.location.search)) {
      ret[match[1]] = match[2];
    }
    return window.parsedSearch = ret;
  })();
  return parsedSearch[variable];
};

 

Thanks hugely in advance for your help.

 

 

Currently I don't think that it is possible to use the Generic JavaScript node to do this. I would recommend trying again to build the Regex for the RegEx Split node. Post back here if you need some help.

Hi

I have managed to get to where i needed by using string manipulation, not ideal but works. For those who need similar solution here is an example;

 

substr($Query$,
(indexOf(lowerCase($Query$),"utm_adgroup" )+12) ,//start of string
(indexOfChars($Query$,"&",indexOf(lowerCase($Query$),"utm_adgroup" ) ))//position of next &
-(indexOf(lowerCase($Query$),"utm_adgroup" )+12 ) //minus start of string
)