Match Regular expression with tFilterRow

One Star

Match Regular expression with tFilterRow

Hi
I tried to use advanced settings of tFilterRow to filter dataflow with regexp, but lacking java knowledge stopped me Smiley Happy
Could someone paste a sample java code for matching with regexp?
Thanks in advance
One Star

Re: Match Regular expression with tFilterRow

I have a similar question to Ruben, I need to have regex expressions in tFilterRow to filter out invalid data type entries from a CSV file.
Thanks for your help.
Zohaib
Seventeen Stars

Re: Match Regular expression with tFilterRow

hi all,
Have a look at api java regex for matches method !
hope it help
laurent
One Star

Re: Match Regular expression with tFilterRow

Kzone,
I'm a newbie to Talend. Could you please let me know where can I write the code that you suggested for the CLASS.
An screenshot or a sample would be of great help.
Thanks a lot,
Zohaib
Seventeen Stars

Re: Match Regular expression with tFilterRow

hi Zohaib,
in fact it's pretty simple.
For example let's match for compliance mail ! (a classic).
In the 'advanced mode' write your condition with the convinience method matches. it does the work for you Smiley Happy
first arg : your regular expression
second arg : string to be parse
the method return boolean
For 'true' goes into filter flow ; when 'false' goes into reject flow.
Right, in my example all email are correct; made one wrong and it goes in reject ...
now you have to write your regex Smiley Wink
hope it help
regards
laurent
One Star

Re: Match Regular expression with tFilterRow

Thanks Kzone!
Seventeen Stars

Re: Match Regular expression with tFilterRow

you welcome Smiley Wink
One Star

Re: Match Regular expression with tFilterRow

Hi I am wondering how to ignore or filter out some data from Input file.
I have columns with no data. and they need to be filtered in the out put file.
How to use TFilterRow ?
Community Manager

Re: Match Regular expression with tFilterRow

Hi I am wondering how to ignore or filter out some data from Input file.
I have columns with no data. and they need to be filtered in the out put file.
How to use TFilterRow ?

Yes, tFilterRow or tMap component can used to do the filter.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Match Regular expression with tFilterRow

Hi ,
I tried to use the advance mode in the tFilterRow to use a regex .
here is the regex : input_row.etab.matches("\"12206\"|\"12906\"|\"16006\"") (i also tried without the \ )
heres is the data I wont to filter :12206 - CR22
12906 - CR29
13306 - CRAQ
13606 - CRIV
14445 - CEBPL
14706 - CRAV
16006 - CR56
16275 - CENFE
17906 - CRAM
18025 - CEPIC
19406 - CRTP

at the end i should have the row with
12206 12906 et 16006.
Instead I got nothing .
What did I miss ??
PS , I also tried : java.util.regex.Pattern.matches("12206|12906|16006", input_row.etab) and got the same results.
One Star

Re: Match Regular expression with tFilterRow

Here is the solution.
It seems the v5 can not handle expression like "12206|12906|16006" or even ("\"12206\"|\"12906\"|\"16006\"") in the basic condition.
Using advance mode does not work either for things input_row.etab.matches("12206|12906|16006")
So I used java.util.regex.Pattern.compile("12206|12906|16006").matcher(input_row.etab).find() to filter my data .
And this time it works .
Hope this help, someone else .
Happy new year .

Hi ,
I tried to use the advance mode in the tFilterRow to use a regex .
here is the regex : input_row.etab.matches("\"12206\"|\"12906\"|\"16006\"") (i also tried without the \ )
heres is the data I wont to filter :12206 - CR22
12906 - CR29
13306 - CRAQ
13606 - CRIV
14445 - CEBPL
14706 - CRAV
16006 - CR56
16275 - CENFE
17906 - CRAM
18025 - CEPIC
19406 - CRTP

at the end i should have the row with
12206 12906 et 16006.
Instead I got nothing .
What did I miss ??
PS , I also tried : java.util.regex.Pattern.matches("12206|12906|16006", input_row.etab) and got the same results.
One Star

Re: Match Regular expression with tFilterRow

Hello,
this works very well. I have an additional question:
How can I customize the error message from the advanced condition.
I would like the error message to not state "advanced condition failed" but "irregular e-mail adress" for example
thanks for any input!