Skip to main content
Question

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

  • February 14, 2018
  • 8 replies
  • 1728 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

8 replies

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

Hi,

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


Forum|alt.badge.img
  • Author
  • February 14, 2018

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+18
  • Enthusiast
  • February 14, 2018
zzupljanin wrote:

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+4
  • Contributor
  • February 15, 2018
oliwerurban wrote:

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+4
  • Contributor
  • February 15, 2018
philippeb wrote:

 

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+44
  • Safer
  • August 28, 2020

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
mark2atsafe wrote:

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.


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