Skip to main content

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

Hi,

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


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


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?

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.

 


 

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.


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.


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.


Reply