Four Stars

Check if a value in a string variable is numeric

Hello,
How can i check if a Value in a string variable in numeric (integer or real).
Thanks for help
Andreas
5 REPLIES
Four Stars

Re: Check if a value in a string variable is numeric

You can use regular expression to validate the string as integer or real.
Vaibhav
Four Stars

Re: Check if a value in a string variable is numeric

Hi Vaibhav,
thanks. But im not good in coding Java. Please do you have some code for me.
Andreas
Seventeen Stars

Re: Check if a value in a string variable is numeric

hi,
java parttern 'shortcut' for that :

\d  : A digit:
\D  :  A non-digit:

you can use a tFilterRow tocheck with contains or matches method.
https://help.talend.com/search/all?query=tFilterRow&content-lang=en
https://stackoverflow.com/questions/15130309/how-to-use-regex-in-string-contains-method-in-java
regards
laurent
Four Stars

Re: Check if a value in a string variable is numeric

sorry but i dont know how i use this in a tjavarow.
Seventeen Stars

Re: Check if a value in a string variable is numeric

use tFilterRow. By that way you can have a flow with data matching pattern & reject flow (data doesn't).
see link above to documentation & example from Talend help.
ps : remember that you have shortcut 'F1' to get help for every component directly from your Talend Studio.
regards
laurent