The following regex will match a GUID in the [8chars]-[4chars]-[4chars]-[4chars]-[12chars] format:
/[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}/i
You could find a GUID within square brackets using the following function:
var re = /\[([a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12})\]/i;
function extractGuid(value) {
// the RegEx will match the first occurrence of the pattern
var match = re.exec(value);
// result is an array containing:
// [0] the entire string that was matched by our RegEx
// [1] the first (only) group within our match, specified by the
// () within our pattern, which contains the GUID value
return match ? match[1] : null;
}
See running example at: http://jsfiddle.net/Ng4UA/26/