java routines to replace regex in a string?

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 GARNER 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

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Download