Skip to main content
Question

How Can I remove everything after "-" in FME using string replacer?

  • February 14, 2018
  • 8 replies
  • 2735 views

Forum|alt.badge.img

Hello.

 

 

I would like to remove (replace with no text) everything what is after dash also with the dash.

 

What I have: test - fme

What I want: test

Cheers,

 

Oliwer

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.

8 replies

zzupljanin
Contributor
Forum|alt.badge.img+5
  • Contributor
  • February 14, 2018

Hi,

If you use StringReplacer with these parameters, that should do the trick...


Forum|alt.badge.img

Thank you very much. That works. Can you please explain me that Expression so I can understand what happened there exactly?


philippeb
Enthusiast
Forum|alt.badge.img+23
  • Enthusiast
  • February 14, 2018

Hi,

If you use StringReplacer with these parameters, that should do the trick...

 

Do you have a website in mind that can generate automatically that kind of expression?

zzupljanin
Contributor
Forum|alt.badge.img+5
  • Contributor
  • February 15, 2018

Thank you very much. That works. Can you please explain me that Expression so I can understand what happened there exactly?

Certainly. So regex is a way to search through your string based on some rules. In this case rules are as follows:

 

\\- means "find - character"

 

.* means "find every character"

 

$ means "until the end of string"

 

 

Together they are: find every character from - character (including) until the end of string.

 

 

If you use FME 2016+ there's a really neat quick reference and testing option inside StringReplacer. With it you can create many of your regular expressions.

 

 

Cheers.

 


zzupljanin
Contributor
Forum|alt.badge.img+5
  • Contributor
  • February 15, 2018

 

Do you have a website in mind that can generate automatically that kind of expression?
Unfortunatelly, I'm not aware of that. There are some that give you explanation based on your expression, though.

 

 


Just to follow up on this. This is how you would remove everything located before the dash.

^.*\\-

 

It took me a few minutes to figure it out so I thought I would share.


mark2atsafe
Safer
Forum|alt.badge.img+59

Since this question has just popped back to the top of the list, I thought I'd mention the hub transformer called LastSectionOfStringRemover, which would probably handle what the original question called for.


donegal_david
Participant
Forum|alt.badge.img+1

Since this question has just popped back to the top of the list, I thought I'd mention the hub transformer called LastSectionOfStringRemover, which would probably handle what the original question called for.

This Transformer is a Godsend... have been scratching the head until i seen your comment @mark2atsafe​ ! I've used it to extract a URL from a Name field extracted from an ESRI Story map. Cheers.