Hitachi Vantara Pentaho Community Forums
Results 1 to 8 of 8

Thread: How to trim user specified characters from string

  1. #1

    Default How to trim user specified characters from string

    Hi,

    Can any one please let me know how to trim user defined characters from string?

    Ex: String value is: "madhurararara", and the output string should be "madhu". The step should trim "ra" from right side from given string.


    Thanks,
    Madhu

  2. #2
    Join Date
    Sep 2007
    Posts
    834

    Default

    Use either a "Replace in string" step or a UDJE step.
    In any of them, you should use regular expressions.

  3. #3

    Default

    Hi,

    I should trim both leading and trailing user defined characters only, but not middle.
    Ex: If String is "-sudhakar-madhu---", then the output string should be "sudhakar-madhu".

    Thanks,
    Madhu

  4. #4

    Default

    Hi,

    I want to trim only leading and trailing user defined characters only, but not replace.

    Ex: If string value is "--sudhakar--madhu--", but the output string should be "sudhakar--madhu".


    Thanks,
    Sudhakar

  5. #5
    Join Date
    Sep 2007
    Posts
    834

    Default

    You can replace anything with "". The effect is the same as removing trailing characters.

  6. #6
    Join Date
    Jun 2012
    Posts
    5,534

    Default Generalized trimming with StringUtils.strip()

    Back to that UDJE step, but without a RE.

    BTW: "string" is the name of the field containing "--sudhakar--madhu--".


    Name:  strip.jpg
Views: 283
Size:  18.2 KB
    So long, and thanks for all the fish.

  7. #7

    Default

    Thank you Very much!!!
    Where can i find this Java expression "org.apache.commons.lang.StringUtils.strip()" in our Pentaho folders?

    Regards,
    Madhu

  8. #8
    Join Date
    Apr 2008
    Posts
    1,771

    Default

    You need to use a User Defined Java Expression and type that line manually (or copy/paste from your browser!)
    -- Mick --

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.