The line in question is this one:
var extendedXmp = (data.match(/xmpNote:HasExtendedXMP="(.+?)"/i) || [])[1];
It is part of the bigger code chunk here:
this.parseCompoundImage = function(data) { var extendedXmp = (data.match(/xmpNote:HasExtendedXMP="(.+?)"/i) || [])[1]; if (extendedXmp) { // we need to clear out JPEG's block headers. Let's be juvenile and don't care about checking this for now, shall we? // 2b + 2b + http://ns.adobe.com/xmp/extension/ + 1b + extendedXmp + 4b + 4b data = data.replace(new RegExp('[\\s\\S]{4}http:\\/\\/ns\\.adobe\\.com\\/xmp\\/extension\\/[\\s\\S]' + extendedXmp + '[\\s\\S]{8}', 'g'), '') } var xmp = data.match(/<x:xmpmeta [\s\S]+?<\/x:xmpmeta>/g), result = {} if (!xmp) throw "No XMP metadata found!"; xmp = xmp.join("\n", xmp); Which comes from the source code of the depthy app. This chunk of code gets XMP metadata and cleans out the JPEG exif headers using regex. The second line of this code is what confuses me. From what I understand is it tries to match a certain pattern in the data, but I'm not familiar enough with javascript to understand it. Can someone explain to me what that line does?
Thanks
matchor the|| [], or the[1]at the end? There's actually a lot going on in that line, and maybe you just need to break it down and try to understand each bit by itself.[], What is it trying to achieve? Finally, the[1]just means taking the second character correct?xmpNote:HasExtendedXMP="FF72..."/>This code matchesFF72.... If the annotation is not present, it replaces it with an empty array. Do you want to write it as an answer so I can accept it?