Hitachi Vantara Pentaho Community Forums
Results 1 to 7 of 7

Thread: How to change '+31" in a string

  1. #1
    Join Date
    Oct 2011
    Posts
    17

    Default How to change '+31" in a string

    I'd like to replace the text '+31' in a field (phonenumber) into an empty string, but only if the '+31' is the only text in the field.
    If the field is filled with "+31 (10)" I don't want the "+31" to be changed, which is happeing in the ReplaceString Step.
    If the field is filled with " +31 (10)" I don't want the "+31" to be changed, which is happeing in the ReplaceString Step.

    I hope someone can give me a clue in how to solve this.
    since I do have multiple fields to do this on< I hope this can be don in one step.

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

    Default

    In the Replace String Step there should be a column that states "whole field" or "whole word" (can't remember without looking up, sorry) - change that to YES.

    Another option is to use the REGEXP option - if you don't know them you can easily find same example using Google - it's worth spending some time getting familiar with that anyway
    Last edited by Mick_data; 05-02-2014 at 06:29 AM. Reason: Add more solution
    -- Mick --

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

    Default

    Still another option would be the Null If utility step.
    So long, and thanks for all the fish.

  4. #4
    Join Date
    Oct 2011
    Posts
    17

    Default

    Hi Mick

    Thanks for your thought, but infortenately this doesn't work for me.

    The actual Option is Whole Word, but even this seems not to work properly (see also my attached combination of screen shots). The actiual '+31' is changed into NULL in the actual '+31' cases. Only there is more changes, like '+31 (0)73-7003400' into ''+(0)73-7003400'. Apperently the '+'-sign has no influence on the ReplaceString Step.

    I've also tried to use the RegEx option, '^(.*\+31).*', but this gives me the same result. Although I'm not 100% sure on the used RegEX OptionValue.
    The actual RegEx Evaluation Step i snot very practical, since I do have to react on the result (either Y or N) but I have 8 Fields to do this.

    So a Whole FIELD option would be best for me.
    Attached Images Attached Images  

  5. #5
    Join Date
    Nov 2009
    Posts
    687

    Default

    Michiel

    You can also use a formula. the formula will look like: if([telefoonnummer]="+31";"";[telefoonnummer])

  6. #6
    Join Date
    Nov 2008
    Posts
    271

    Default

    Null if, as per marabu's hint, works fine. Alternatively, the right regex pattern is simply ^\+31$.

    This one matches exactly '+31', i.e. there must be no trailing spaces for the match to be successful.
    Andrea Torre
    twitter: @andtorg

    join the community on ##pentaho - a freenode irc channel

  7. #7
    Join Date
    May 2014
    Posts
    9

    Default

    Hi Michiel,

    my suggestion is, use modified javascript value in folder scripting, just check value of string, like :
    if( phonenumber == "+31")
    {
    phonenumber="";
    }


    by,
    Hartz

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.