Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: removing whitespace using regular expression

  1. #1

    Default removing whitespace using regular expression

    input required....

    as part of a load transformation of date from text file (CSV) into a MySQL 5.1 database.

    I have product field with blank spaces in the word.
    To remove them I am using replace javascript function with regular expression as follows:

    PRODUCT.replace(/\s+/g," ");
    whitespace are NOT replaced with single space as required.

    If I remove the reg expression and put in the exact amount of spaces for one example of the product the replace works like it should as follows:

    PRODUCT.replace(" "," ");

    Clearly there is an issue with my regular expression although I have tried it with a test word instead of the PRODUCT field and it works.

    Anyone have any ideas, Christoph if you see this do you have any further input.

    THanks
    Tom

  2. #2
    DEinspanjer Guest

    Default

    A simple test of that certainly appears to work for me (at least in 3.1). I'd suspect user error. Are you remembering to save the results of your method call into a new variable?
    e.g.
    var SQUEEZED_PRODUCT = PRODUCT.replace(/\s+/g, " ");

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.