str = attrib1 function formatEntity (str) { // delete /Alpha/Dr/Oerd/ // delete Alpha/Aqs/ str = str.replace( /\/Alpha\/Dr\/Oerd\/?/gi,""); str = str.replace( /\/Alpha\/Aqs\/?/gi,""); //replace ----/Fox/Sdf/---- by Sdf/ str = str.replace( /\/Fox\/Sdf\//g,"Sdf/"); //replace ----/Fox/Apcr/---- by Apcr/ str = str.replace( /\/Fox\/Apcr\//g,"Apcr/"); //replace ----/Fox/Aqsz/---- by Aqsz/ str = str.replace( /\/Fox\/Aqsz\//g,"Aqsz/"); //replace ----/Oxa/Abdr/---- by Abdr/ str = str.replace( /\/Oxa\/Abdr\//g,"Abdr/"); // UpperCase the string str = str.replace( /\w/gi, function (x) { return x.toUpperCase(); }); // delete the last "/" str = str.replace(/\/$/g, ""); // replace remain "/" by _ str = str.replace(/\//g, "_"); System.log(str) }Merci !
Hi,
Your function lacks the 'return' statement that will return the formatted value.
Something like the following should work:
// Original attributes
attrib1 = "/Fox/Sdf/Acd/Opf/";
attrib2 = "/Fox/Aqsz/Dre/Pqf/";
// Format and assign back
attrib1 = formatEntity(attrib1);
attrib2 = formatEntity(attrib2);
// Print formatted attributes
System.log(attrib1);
System.log(attrib2);
function formatEntity (str) {
// Your original function code goes here...
// ...
// At the end, return the formatted result as computed by your function
return str;
}
Woow thank you very much for your reactivity !
is it possible to store all the regex part in a resource element and call it ?
Thanks again !!!!
The right approach is to store the formatEntity function as a vRO scripting action (not as resource element), which will make it available to be called by other scripting actions / workflows.
Sure, you can extrnalize the regular expression and store it in resource element (or configuration element). But be aware that: