Skip to main content
Question

string replacer with numbers

  • November 4, 2014
  • 4 replies
  • 55 views

danpaoly
Contributor
Forum|alt.badge.img+1
I have a value of FAIRFIELD WORKS, FAIRFIELD, AL 35064 that I need to change to FAIRA.  However I am getting FAIRA 35064.  I have my string replacer set as follows

 

 

Text to Find: FAIRFIELD WORKS, FAIRFIELD, AL 35064

 

Replacement Text: FAIRA

 

Use regular Expressions: No

 

Case Sensitive: No

 

 

How can I get rid of 35064.

 

 

thanks

 

Dan
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.

4 replies

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • November 4, 2014
regexp = (.*)\\s\\d*

 

 

Use regular Expressions: YES

 

 

expose or use creator or renamer on "matched_parts{0}"

danpaoly
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • November 4, 2014
does this work with conditional parameters?  I have other values in the field such as Warren, OH that do not need changed or do I need to add a Tester

 

 

takashi
Celebrity
  • November 5, 2014
Hi Dan,

 

 

Please check the input attribute value.

 

If the attribute stores "FAIRFIELD WORKS, FAIRFIELD, AL 35064 35064" (the number is duplicated), the resulting string will be "FAIRA 35064" naturally. 

 

 

Takashi

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • November 5, 2014
Lol Takashi,

 

 

i changed the regexp to ([a-zA-Z,\\s]*)\\s\\d*

 

(FME regexp flavor does'nt want to do

 

 (.*)\\s\\d* or ([\\w,\\s]*)\\s\\d* Though in other aplications it works like above)

 

 

 

 

If u have specific objects that need changed u need to test for those yes.

 

In conditional you need to use different aproach, u can  use tcl string and listfunctions.

 

Though this is somewhat more complex

 

 

You could do like conditional:

 

test condition: 

 

@Value(adres) like %FAIRFIELD%

 

outputfield:@Evaluate([string replace {@Value(tst)} @Evaluate([lindex {@Evaluate(@Evaluate([regexp -indices {(.*)\\s\\d*} {@Value(tst)} M SM])==1?"$SM":"none")} 0]) @Evaluate([lindex {@Evaluate(@Evaluate([regexp -indices {([a-zA-Z,\\s]*)\\s\\d*} {@Value(tst)} M SM])==1?"$SM":"none")} 1]) {@Value(Replacement)}])

 

 

...;)

 

i set a attribute @Value(Replacement) to "FAIRA "

 

 

this replaces "FAIRFIELD WORKS, FAIRFIELD, AL 35064" to "FAIRA 35064"

 

 

You might not want to go there and just use transformers: tester, stringsearchers and stringreplacers.