Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Flag 1 if numeric, 0 if not (Regex/Replace in String?)

  1. #1
    Join Date
    Dec 2016

    Default Flag 1 if numeric, 0 if not (Regex/Replace in String?)


    What's the best way to do this? I have a string field and I'd like to evaluate each value in this field to see if it could be cast as a number(double).

    I can pick up a number followed by 1 decimal place using regex & replace in string, but can you tell me how I should configure it so I get to an output field with flags of 1 or 0 only?

    Much obliged,


  2. #2
    Join Date
    Jun 2012


    With a complex tool like Kettle there are many ways to achieve this.

    If non-numeric values represent errors, you should use a Select-Values" step (tab Meta-Data) to convert from String to Number with error handling enabled. Add-Constants will create the flag field, then.

    Or use a User-Defined-Java-Expression like: org.apache.commons.lang.math.NumberUtils.isNumber(stringField) ? 1 : 0
    So long, and thanks for all the fish.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.