So I have a bunch of columns like Red1, Red2... Red10, Red11 and I want to rename them to all have two digits, so Red01, Red02, etc.
Is there a more efficient way to rename all of those other than using a select tool and manually doing it ?
Solved! Go to Solution.
You could check the Dynamic Rename tool, (under the developer tab) which will allow you to mass rename using a formula with REGEX_Replace in it, (e.g. to replace [0-9] with a preceding zero).
Robert,
Here is a formula that yields something similar to what you've asked for. Maybe not the best logic, but it should get the job done for you.
IF REGEX_MATCH([_CurrentField_],"([[:alpha:]]+)(\d{1})")
THEN REGEX_REPLACE([_CurrentField_],"([[:alpha:]]+)(\d)","$1_0$2")
ELSE REGEX_REPLACE([_CurrentField_],"([[:alpha:]]+)(\d)","$1_$2")
ENDIF
Thanks,
Mark
When I use that formula, it changes it to Red_01 is their anyway to eliminate that _ I imagine another regex ?
Robert,
Only for you ...
IF REGEX_MATCH([_CurrentField_],"([[:alpha:]]+)(\d{1})")
THEN REGEX_REPLACE(REGEX_REPLACE([_CurrentField_],"([[:alpha:]]+)(\d)","$1_0$2"),"([[:alpha:]]+)(_)(\d)","$1$3")
ELSE REGEX_REPLACE([_CurrentField_],"([[:alpha:]]+)(\d)","$1$2")
ENDIF
You saved me this morning!