Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: Removing White Space and Replace Characters?

  1. #1

    Question Removing White Space and Replace Characters?

    I have a 2 pronged question. First, I have used the REGEX step successfully in transformations, but I use it when the string is consistent or predictable. I am trying to remove any white space (spaces) in a stream field - sometimes there will be some spaces and other instances there will not.

    Example:

    Volume 0022F
    LUN xyz
    abc

    Desired:

    Volume0022F
    LUNxyz
    abc

    Lastly, I want to replace specific characters. Example:

    FA:10:bb:03
    FA:AB:10

    Desired:

    FA_10_bb_03
    FA_AB_10

    Thanks in advance!!!

    KP

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

    Default

    Here's a way to translate and eliminate characters from a string in one go: replaceChars()

    Name:  replaceChars.jpg
Views: 719
Size:  12.6 KB
    So long, and thanks for all the fish.

  3. #3

    Default

    Wow! This worked great and now I can use this step in many other transforms! So for removing white space I used this:

    org.apache.commons.lang.StringUtils.replaceChars(LUN_ALIAS," ",null)

    Outcome - Column2 is desired outcome:

    LUN,LUN_ALIAS
    LUN 12,LUN12
    LUN 13,LUN13
    LUN 14,LUN14
    LUN 15,LUN15
    LUN 16,LUN16
    LUN 17,LUN17

    Thank you .. AGAIN

    KP
    Last edited by karlis_peterson; 01-18-2014 at 10:10 AM.

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.