Skip to main content
Solved

Use Stringreplacer to remove data contained in brackets? e.g. "Akermaat (A9 Alkmaar - Amsterdam)"

  • November 1, 2016
  • 5 replies
  • 256 views

Hi all,

I'm trying to remove some unwanted data using StringReplacer.

 

I'd like to remove all data contained within brackets and also remove the brackets themselves.

What I have:

Alblasserdam (A15 Sliedrecht – Ridderkerk)

 

Bospoort (A4 Schiphol - Den Haag)

 

What I want:

 

Alblasserdam

 

Bospoort

 

 

Can I use StringReplacer for this?

Thanks,

Ed

Best answer by takashi

Hi @edttom, yes, I think the StringReplacer with this setting does the trick.

  • Text to Find: \\s*\\(.*?\\)
  • Replacement Text: <not set>
  • Use Regular Expressions: yes
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.

5 replies

takashi
Celebrity
  • Best Answer
  • November 1, 2016

Hi @edttom, yes, I think the StringReplacer with this setting does the trick.

  • Text to Find: \\s*\\(.*?\\)
  • Replacement Text: <not set>
  • Use Regular Expressions: yes

  • Author
  • November 1, 2016

Many thanks for the fast response @takashi , it worked!

 

However, I'm curious as to what "\\s*\\(.*?\\)" does. Can you clarify or point me to some documentation explaining this query?

Thanks


takashi
Celebrity
  • November 1, 2016

Many thanks for the fast response @takashi , it worked!

 

However, I'm curious as to what "\\s*\\(.*?\\)" does. Can you clarify or point me to some documentation explaining this query?

Thanks

The help doc on the StringSearcher and the StringRepalcer contains short description about regular expressions. Then, see also these links to learn more.

 


takashi
Celebrity
  • November 1, 2016

Many thanks for the fast response @takashi , it worked!

 

However, I'm curious as to what "\\s*\\(.*?\\)" does. Can you clarify or point me to some documentation explaining this query?

Thanks

Addition.

 

  • \\s* 0 or more whitespaces
  • \\( an opening round bracket
  • .*? 0 or more any characters (? indicates that "matches the minimum length" in this case)
  • \\) a closing round bracket

arekpierchala
Contributor
Forum|alt.badge.img+1
  • Contributor
  • November 2, 2016

Many thanks for the fast response @takashi , it worked!

 

However, I'm curious as to what "\\s*\\(.*?\\)" does. Can you clarify or point me to some documentation explaining this query?

Thanks

Takashi gave you most elegant solution.

 

It is Regular Expresion.

 

Watch how it works e.g. at http://rubular.com/ or directly in FME when open properties of 'Text to Match' if 'Use Regular Expression' is maked to 'yes'