const regex = /"value":"[a-zA-z\s.]+/;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('"value":"[a-zA-z\\s.]+', '')
const str = `"{"error":{"code":"/IWBEP/CM_MGW_RT/022","message":{"lang":"en","value":"Active Delegation already Exists."},"innererror":{"transactionid":"5560F03E45262DE0E10080000A492395","timestamp":"","Error_Resolution":{"SAP_Transaction":"","SAP_Note":""},"errordetails":[{"code":"/IWBEP/CX_MGW_BUSI_EXCEPTION","message":"Active Delegation already Exists","propertyref":"","severity":"error","target":""}]}}}"`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
if ((m = regex.exec(str)) !== null) {
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions