JSFiddle - React, Tailwind, and code Playground
HTML
<div id="log"></div>
JavaScript
var re = /\[([a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12})\]/i;
// finds first occurrence of a GUID within square brackets in a string
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;
}
function test(value) {
var guid = extractGuid(value);
var msg;
if(guid ) {
msg = 'Guid found within ' + value+ ': ' + guid;
} else {
msg = 'Guid not found within ' + value;
}
$('#log').append(msg + '<br/><br/>');
}
test('AccommPropertySearchModel.AccommPropertySearchRooms[6a2e6a9c-3533-4c43-8aa4-0b1efd23ba04].ADTCount');
test('AccommPropertySearchModel.AccommPropertySearchRooms[6a2e6a9c-3533-4c43-8aa4-0b1efd23ba04].ADTCount');
test('AccommPropertySearchModel.AccommPropertySearchRooms[6A2E6A9C-3533-4C43-8AA4-0B1EfD23BA04].ADTCount');
test('AccommPropertySearchModel.AccommPropertySearchRooms.6A2E6A9C-3533-4C43-8AA4-0B1EfD23BA04.ADTCount');
test('AccommPropertySearchModel.AccommPropertySearchRooms.ADTCount');