diff --git a/src/app/core/substance-ssg2/substance-ssg2-form.service.ts b/src/app/core/substance-ssg2/substance-ssg2-form.service.ts index bdb1d9935..4f385016b 100644 --- a/src/app/core/substance-ssg2/substance-ssg2-form.service.ts +++ b/src/app/core/substance-ssg2/substance-ssg2-form.service.ts @@ -1424,7 +1424,10 @@ export class SubstanceSsg2FormService implements OnDestroy { substanceString = JSON.stringify(substanceCopy); deletedUuids.forEach(uuid => { - substanceString = substanceString.replace(new RegExp(`"${uuid}"`, 'g'), ''); + const pattern = /^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/; + if(pattern.test(uuid)) { + substanceString = substanceString.replace(new RegExp(`"${uuid}"`, 'g'), ''); + } }); substanceString = substanceString.replace(/,[,]+/g, ','); substanceString = substanceString.replace(/\[,/g, '[');