Skip to main content
Solved

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

  • November 1, 2016
  • 5 replies
  • 206 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
View original
Did this help you find an answer to your question?
<strong>This post is closed to further activity.</strong><br /> It may be a question with a best answer, an implemented idea, or just a post needing no comment.<br /> If you have a follow-up or related question, please <a href="https://community.safe.com/topic/new">post a new question or idea</a>.<br /> If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

takashi
Evangelist
  • 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
Evangelist
  • November 1, 2016
edttom wrote:

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
Evangelist
  • November 1, 2016
edttom wrote:

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

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'

 

 


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