JavaScript remove GUID brackets

Most of Microsoft system will use the GUID(Global Unique Identifier) as the primary record key. It is 32 bit Character long String and 16 byte binary data type which is used for global identification of records. Thus, we should get the record by using the GUID as the search key. 

3 ways using JavaScript remove GUID brackets

var userId = '{E29FF38C-D95B-EB11-B80F-02BFAC1001DC}'
Code language: JavaScript (javascript)

You can use

var id = userId.replace('{', '').replace('}', '');
Code language: JavaScript (javascript)

Or

var id = userId.replace(/[{}]/g, '');
Code language: JavaScript (javascript)

Or

var id = userId.substring(1, 37);
Code language: JavaScript (javascript)

Hope this help you 🙂

Leave a Reply