Skip to main content
Question

StringReplacer Doesn't Work? Remove characters before and after

  • January 18, 2022
  • 5 replies
  • 285 views

I have two scenarios; In Column A, I need everything before a set of string, and in Column B, I need everything after a set of string, by using StringReplacer. Below is an example of what I am trying to do:

 

COUNTY OF PRINCESTON

REGION COUNTIES OF LAMBERSON

 

Column A:

COUNTY

REGION COUNTIES

 

Column B:

PRINCESTON

LAMBERSON

 

in the StringReplacer, I have the expression

^.*\\ OF for everything before

\\ OF ,*$ for everything after

 

Based on a previous forum https://community.safe.com/s/question/0D54Q000080hTpzSAE/how-can-i-remove-everything-after-in-fme-using-string-replacer

 

image 

The result of this is that there are no changes to the strings, as everything before and after the ' OF ' remained in the columns.

 

5 replies

takashi
Influencer
  • January 18, 2022

Hi @shirley821​ , these expressions could help you. Here, \\b matches boundary of word, \\s* matches zero or more spaces.

.*\\bOF\\b\\s*

\\s*\\bOF\\b.*


  • Author
  • January 18, 2022

Hi @Takashi Iijima​ Thank you so much, It worked like a charm!! I am wondering where can I find out more about these expressions?


takashi
Influencer
  • January 18, 2022
shirley821 wrote:

Hi @Takashi Iijima​ Thank you so much, It worked like a charm!! I am wondering where can I find out more about these expressions?

You can find many sites regarding regular expressions on the Web, but I would recommend you to visit this site, which contains quick start, tutorial, example, detailed reference etc.

Regular-Expresions.info

Note that there are several regular expression flavors and could be slightly different in syntax and functions amongst them in some parts. See the site above to learn more.

I think FME basically uses the PCRE library but am not sure it's version. Hope someone from Safe clarifies this. @danatsafe​ 


DanAtSafe
Safer
Forum|alt.badge.img+18
  • Safer
  • January 29, 2022
takashi wrote:

You can find many sites regarding regular expressions on the Web, but I would recommend you to visit this site, which contains quick start, tutorial, example, detailed reference etc.

Regular-Expresions.info

Note that there are several regular expression flavors and could be slightly different in syntax and functions amongst them in some parts. See the site above to learn more.

I think FME basically uses the PCRE library but am not sure it's version. Hope someone from Safe clarifies this. @danatsafe​ 

@takashi Yes, FME uses Qt which is based on the latest PCRE library.


takashi
Influencer
  • January 29, 2022
takashi wrote:

You can find many sites regarding regular expressions on the Web, but I would recommend you to visit this site, which contains quick start, tutorial, example, detailed reference etc.

Regular-Expresions.info

Note that there are several regular expression flavors and could be slightly different in syntax and functions amongst them in some parts. See the site above to learn more.

I think FME basically uses the PCRE library but am not sure it's version. Hope someone from Safe clarifies this. @danatsafe​ 

Thank you for your clarification, @danatsafe​ ​


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