Tuesday, March 3, 2015

Handling Escaped Characters in Talend

Hi,
We are saving our string data into database after handling Escaped Character.
E.g. \n \t \b etc.

traditionally we use tFilterRows or tMap expressions for this.

But today I tell you how to use tScriptRules component for the same.
download this component from exchange from below url -
https://www.talendforge.org/exchange/?eid=360&product=tos&action=view&nav=1,0,0


Source data-



in above note the row 5-
'Rajul', '3240 Mahindra Park\n behind hdfc bank'

The objective is to find all addresses having \n Escaped Character.



Use expression below in tScriptRules-

"input_row.address_street =~ '.*(\\n).*'"

Note: Rules -- expressions that evaluate to true or false -- are created using a Javascript-like language called JEXL.

We can also handle email validation like finding string having yahoo.com at last by-

"input_row.field_name =~ '.*yahoo.com$'"

We can also use && and || expression in tScriptRules.


The Output-







No comments:

Post a Comment