figured it out with this –
// Original text
var originalText = “© 2025 XYZ Corp. All Rights Reserved. YYY-ZZ-XXXXX“;
// Substring to replace
var substringToReplace = “YYY-ZZ-XXXXX“;
// Layer to Replace From
var otherLayer = thisComp.layer(“REPLACE TEXT”);
// New substring
var newSubstring = otherLayer.text.sourceText.value.substring(0, 50);
// Replace the substring
var newText = originalText.replace(substringToReplace, newSubstring);
newText;