java routines to replace regex in a string?

Highlighted
Six Stars

java routines to replace regex in a string?

Hi everyone

is it possible to create a java routines which can replace regex instead of using the tReplace component?
Example: There is a table which contains product column and product_description column.

This description also includes the words "do not offer" in different kinds like:
DO NOT OFFER, Do Not Offer, Do NOT Offer, don't offer, DON'T OFFER and some other writings.

Now those words have to replace by an empty space.

Is there an easy way to replace all different writings?

 

Thanks for any information.

Nine Stars

Re: java routines to replace regex in a string?

Hi,

 

"Easy way", not sure but you can of course create a routine with a method that will remove all possible occurences of your list.

 

Please note that you can easily make a regex case unsensitive by adding "(?i)" at the beginning.

 

For example this :

"nice product Do NoT OfFeR to client".replaceAll("(?i)do not offer","")

will return that :

nice product  to client

 

Of course, it's not very clean Smiley Wink and you'll have to ajust every time you see a new variation...

 

Regards

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog