Skip to main content
Solved

Adding Number in front of a existing Attribute

  • November 14, 2019
  • 6 replies
  • 159 views

Forum|alt.badge.img

Hi guys,

 

I have the following attributes:

783

784

AYH

I would like to add 1 in front of any attribute starting with 7 and avoid adding to another field. What would be the best transformer to use for this? I have tried and tested the stringpadder but can't seem to get it working. Any help would be great.

Best answer by danullen

StringReplacer with Replace Regular Expression: Replace ^7 with 17. That finds any values starting (^) with 7.

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.

6 replies

Forum|alt.badge.img
  • 104 replies
  • Best Answer
  • November 14, 2019

StringReplacer with Replace Regular Expression: Replace ^7 with 17. That finds any values starting (^) with 7.


Forum|alt.badge.img
  • Author
  • 25 replies
  • November 14, 2019

StringReplacer with Replace Regular Expression: Replace ^7 with 17. That finds any values starting (^) with 7.

Thank you again Dan, learning all the time. Much appreciated.


jkr_wrk
Influencer
Forum|alt.badge.img+35
  • 424 replies
  • November 14, 2019

You should use a BulkAttributeRenamer for this.

Rename selected attributes

Select all attributes that start with a 7

 

Add String Prefix

 

Rename

 

String: 1

 

I see i didn't understand your question correctly. I thought you wanted to rename the attribute name not the attribute value.


Forum|alt.badge.img
  • Author
  • 25 replies
  • November 14, 2019

You should use a BulkAttributeRenamer for this.

Rename selected attributes

Select all attributes that start with a 7

 

Add String Prefix

 

Rename

 

String: 1

 

I see i didn't understand your question correctly. I thought you wanted to rename the attribute name not the attribute value.

No issue @jkr_da Thanks for your help


Forum|alt.badge.img
  • 104 replies
  • November 14, 2019

Thank you again Dan, learning all the time. Much appreciated.

No problem! :) Regexes are very often the solution, so make use of the Regular Expression Editor in FME in the transformers that have it, or use regex101.com or similar to test your ideas for complex regex-strings.


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • November 14, 2019

There's also the option to use an attributecreator with a conditional statement

If the value of attribute begins with 7 create a new value of 1 and existing attribute otherwise do nothing