Q: Extract the date string from string using regex I want to find all datetime substrings from the below sample string that start with CAST( and end with DateTime):
CAST(0x0000A21E000DD2C1 AS DateTime), 1, '98ac498b-89b6-434a-808d-020e82a59c82't, CAST(0x0000A20000C35DF7 AS DateTime), CAST(0x0000A20000C35DF7 AS DateTime), 1, 4, CAST(0x0000A20000C7558A AS DateTime)

Edit
I want to find out all the individual entries like CAST(0x0000A21E000DD2C1 AS DateTime) from the string.
Thanks,
Chetan

A: /(CAST\([^\)]* AS DateTime\))/g
Matches:
CAST(0x0000A21E000DD2C1 AS DateTime)
CAST(0x0000A20000C35DF7 AS DateTime)
CAST(0x0000A20000C35DF7 AS DateTime)
CAST(0x0000A20000C7558A AS DateTime)

Sample code:
var re = /(CAST\([^\)]* AS DateTime\))/g; 
var str = 'CAST(0x0000A21E000DD2C1 AS DateTime), 1, \'98ac498b-89b6-434a-808d-020e82a59c82\'t, CAST(0x0000A20000C35DF7 AS DateTime), CAST(0x0000A20000C35DF7 AS DateTime), 1, 4, CAST(0x0000A20000C7558A AS DateTime)';
var m;

while ((m = re.exec(str)) != null) {
    if (m.index === re.lastIndex) {
        re.lastIndex++;
    }
    // View your result using the m-variable.
    // eg m[0] etc.
}

See demo
