Skip to main content
Solved

String Removal


Forum|alt.badge.img

Hi.

Im new to FME and this seems like a simple one.

 

I have an attribute called type and within it the following values

 

 

Floor:FLR1009

 

Slab:SLB2435

 

DOR-1000

 

WAL-2000

 

 

I want to remove the Floor: and the Slab:

 

Id rather use a string renamer if possible as the Floor: and Slab: will be constant.

 

 

Thanks

 

Chris.

Best answer by takashi

Yes, it seems to be a case where you can use regular expressions effectively and I agree that the StringSearcher would be a good starting point. If you have been familiar with regular expressions already, however, I think the StringReplacer would be an elegant solution to remove the leading "Floor:" or "Slab:" from each string value. The parameters would be:

  • Attributes: type
  • Text to Match: ^(Floor:|Slab:)?(.*)$
  • Replacement Text: \\2
  • Use Regular Expressions: yes

View original
Did this help you find an answer to your question?

11 replies

fmelizard
Contributor
Forum|alt.badge.img+17
  • Contributor
  • January 13, 2017
Hi @cfordigan. What is your question about string removal?

 


Forum|alt.badge.img
  • Author
  • January 13, 2017
Hi.

 

 

Im new to FME and this seems like a simple one.

 

 

I have an attribute called type and within it the following values

 

 

Floor:FLR1009

 

Slab:SLB2435

 

DOR-1000

 

WAL-2000

 

 

I want to remove the Floor: and the Slab:

 

 

Id rather use a string renamer if possible as the Floor: and Slab: will be constant.

 

 

Thanks

 

 

Chris.

 

 

 

 


fmelizard
Contributor
Forum|alt.badge.img+17
  • Contributor
  • January 14, 2017

I would suggest by starting checking out the StringSearcher. You could use two, one to remove Floor: and the other Slab:

 

Good luck!

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • Best Answer
  • January 14, 2017

Yes, it seems to be a case where you can use regular expressions effectively and I agree that the StringSearcher would be a good starting point. If you have been familiar with regular expressions already, however, I think the StringReplacer would be an elegant solution to remove the leading "Floor:" or "Slab:" from each string value. The parameters would be:

  • Attributes: type
  • Text to Match: ^(Floor:|Slab:)?(.*)$
  • Replacement Text: \\2
  • Use Regular Expressions: yes


Forum|alt.badge.img
  • Author
  • January 14, 2017

fantastic. It worked a dream!

Thanks so much.


Forum|alt.badge.img
  • Author
  • January 16, 2017

Hi Again,

Can I ask, when I have a field like

Assembled Stair:

It replaces the Assembled, but not the Stair:

I have tried putting a . between the Assembled.Stair

To replace a full string and not one word, is there something I need to do perhaps?

Thanks again for your help

Chris

 


fmelizard
Contributor
Forum|alt.badge.img+17
  • Contributor
  • January 16, 2017
cfordigan wrote:

Hi Again,

Can I ask, when I have a field like

Assembled Stair:

It replaces the Assembled, but not the Stair:

I have tried putting a . between the Assembled.Stair

To replace a full string and not one word, is there something I need to do perhaps?

Thanks again for your help

Chris

 

@cfordigan What transformer are you using? What have you entered for the transformer parameters? Thanks

 


Forum|alt.badge.img
  • Author
  • January 16, 2017

Hi Natalie,

This is what Im using and all but the last part works perfectly.

The Assembled Stair: returns Stair: and I think because of the space, so Ive tried \\s. It works OK with the regex tester but I doesnt replace the string in FME.

Do you think this is the best way to remove this also? I may have up to 10 strings to replace.

^(Structural_Columns_UC-Univeral_Column:|Floor:|Railing:|Basic Wall:|Assembled\\sStair:)

Thanks for your help.

Chris


ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • January 16, 2017

You may be better off using a string pair replacer here with the Replacement pairs syntax something like

"Assembled Stair:" "" Floor: "" Railing: ""


ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • January 16, 2017
ebygomm wrote:

You may be better off using a string pair replacer here with the Replacement pairs syntax something like

"Assembled Stair:" "" Floor: "" Railing: ""

The regex ^(Structural_Columns_UC-Univeral_Column:|Floor:|Railing:|Basic Wall:|Assembled\\sStair:)?(.*)$ works for me in the String Replacer though

 

 

What version of FME are you using?

 

 


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • January 17, 2017

I guess that the requirement is to remove the leading part until the colon if the original string contains a colon. If so, the StringReplaceer with this regular expression could work too.

^(.*:)?(.*)$

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings