Skip to main content
Solved

I have a column that contains a lot of special characters. By using transformer 'StringReplacer', I can replace i.e. an '#' by an ' '; How can I replace a list of special characters of 10 or more characters. Do I need to use 10 StringReplacers?

  • Nov 29, 2023 1:47 PM UTC
  • 5 replies
  • 280 views

I have a column that contains a lot of special characters. By using transformer 'StringReplacer', I can replace i.e. an '#' by an ' '; How can I replace a list of special characters of 10 or more characters. Do I need to use 10 StringReplacers?

Best answer by itsmatt

Another optoin is to use a reular expression - this one should work:

!|"|§|\$|%|/|\(|\)|\=|\?|\\|\*|\+|'|#

The "|" charachter in a reqular expression is like a logical OR. You need to use "\" to escape some of the charachters.

imageimage 

View original
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

dustin
Influencer
Forum|alt.badge.img+36
  • Influencer
  • Nov 29, 2023 1:55 PM UTC

How is the column with the special characters structured? Space delimited? Comma delimited?


  • Author
  • Nov 29, 2023 2:02 PM UTC

I read the column from a database. All characters used are readable. Every record in this column is varchar(100). I need to change most of the special characters by ' '; my special character list that need to be replaced are: !"§$%/()=?\\*+'# but not &-


david_r
Celebrity
  • Nov 29, 2023 2:14 PM UTC

Did you look at the StringPairReplacer? Note that you must use <backslash>+<space> to indicate that you want to replace something with a <space>, as explained in the documentation. Example to replace # and ! with a space:

# \  ! \ 

 


itsmatt
Celebrity
Forum|alt.badge.img+48
  • Celebrity
  • Best Answer
  • Nov 29, 2023 2:25 PM UTC

Another optoin is to use a reular expression - this one should work:

!|"|§|\$|%|/|\(|\)|\=|\?|\\|\*|\+|'|#

The "|" charachter in a reqular expression is like a logical OR. You need to use "\" to escape some of the charachters.

imageimage 


  • Author
  • Nov 29, 2023 3:00 PM UTC

Another optoin is to use a reular expression - this one should work:

!|"|§|\$|%|/|\(|\)|\=|\?|\\|\*|\+|'|#

The "|" charachter in a reqular expression is like a logical OR. You need to use "\" to escape some of the charachters.

imageimage 

Excellent!