Highlighted
Five Stars

## Business Rule for decimal values

Hello,

I'm trying to define a business rule to check if my input is a numeric value or not.

Here's my input:

I've applied the next rule in a tMap but unfortunetely it doesn't work (the output gives me zeros):

StringHandling.LEN(out5.Volumen_DM3) > 0 &&
out5.Volumen_DM3.matches("^[0-9]+\$")? 1:0

In my tMap input this field is defined as a string and the output is an integer since I've established 1 for correct and 0 incorrect.

Could anyone help me with this rule?

Thank you!!

Marc

Accepted Solutions
Sixteen Stars

## Re: Business Rule for decimal values

Try "^[0-9,\.]+\$" or maybe "^[0-9,\\.]+\$"

TRF

All Replies
Sixteen Stars

## Re: Business Rule for decimal values

This one works:

`StringHandling.LEN(row1.volume) > 0 && row1.volume.matches("^[0-9,]+\$") ? 1 : 0 `

Just add a comma into the brackets.

TRF
Sixteen Stars

## Re: Business Rule for decimal values

Does this help?
If so, thanks to mark your case as solved.

TRF
Five Stars

## Re: Business Rule for decimal values

Hello,

It works but I have still problems when the input value has a ".", for example: 1.503,67

Do you know what I would have to add in order to solve the problem?

Thank you!!

Sixteen Stars

## Re: Business Rule for decimal values

Try "^[0-9,\.]+\$" or maybe "^[0-9,\\.]+\$"

TRF
Five Stars

## Re: Business Rule for decimal values

It works! Thank you!!

Sixteen Stars

You're welcome

TRF

## OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

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