I have attribute zip code, where all values looks in this form 12345 how can I transform them into this form 123 45?
My idea was to split it using StringReplacer where I would replace \\d{5} by \\d{3} \\s \\d{2}, however I don't know how can I create new attribute which base on the old zip code attribute (12345).
Are there any other ways to do it?
Best answer by takashi
Hi @vid, I think the StringReplacer is a right way. If you need to preserve the original value, copy the original value to a new attribute with the AttributeCopier, then modify it with the StringReplacer transformer.
Parameters Setting Example:
Mode: Replace Regular Expression
Text to Replace: (\\d\\d)$
Replacement Text: \\1 (a single space and '\\1')
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.
Hi @vid, I think the StringReplacer is a right way. If you need to preserve the original value, copy the original value to a new attribute with the AttributeCopier, then modify it with the StringReplacer transformer.
Hi @vid, I think the StringReplacer is a right way. If you need to preserve the original value, copy the original value to a new attribute with the AttributeCopier, then modify it with the StringReplacer transformer.
Parameters Setting Example:
Mode: Replace Regular Expression
Text to Replace: (\d\d)$
Replacement Text: \1 (a single space and '\1')
Alternatively, you can also use the @ReplaceRegEx function to directly create a new zip code from the original code, in a parameter field such as 'Attribute Value' field in the AttributeCreator. e.g.
Hi @vid, I think the StringReplacer is a right way. If you need to preserve the original value, copy the original value to a new attribute with the AttributeCopier, then modify it with the StringReplacer transformer.