Hello all, I'm building a data cleanup tool in model-builder using the 'Calculate' field and the the .replace() function. It's working well except for one problem, the values that I am updating are to include text string parts valuesin the original attributes. So the replace function behaves as though there are endless wildcards in the field. Is there a way to limit the replace function to change those field values where the first variable is as exactly as it is in the function 'Demo' vs '%Demo%'? I figure it's got to be something easy I'm overlooking.
function: !Project_Type!.replace('Demo','Demolition')
original value: Demo
intended value: Demolition
returned value: Demolitionlition
Solved! Go to Solution.
It seems like a band-aid, but you could add a conditional (if x like %demolition%) to not replace the same string more than once. Or, better yet, use conditionals to test if the replace function should run on a given value (if x == 'demo').
It seems like a band-aid, but you could add a conditional (if x like %demolition%) to not replace the same string more than once. Or, better yet, use conditionals to test if the replace function should run on a given value (if x == 'demo').
This was the casecracker! I was trying to gather the group of values I wanted to change instead of using a conditional for a specific value. Thanks Joe!