Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9304259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:40:07+00:00 2026-06-18T23:40:07+00:00

I have several thousands of rows that I’m loading into a database utilizing Pentaho.

  • 0

I have several thousands of rows that I’m loading into a database utilizing Pentaho. I must keep the string value length at 4 characters. The source file may only have a single character but it is still needed to keep the length at 4 characters to maintain consistency in the database.

Example:
Source: 10
Database expected results: 0010

I’m using a replace in string transformation or could use a java expression, which ever one works. Please help and provide a resolution utilizing either method (Regex or Javascript expression).

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T23:40:08+00:00Added an answer on June 18, 2026 at 11:40 pm

    In Java you can use String.format(...) with a format specifier to pad your number with zeroes to 4 digits:

    String.format("%04d", yournumber);
    

    In Javascript you can use sprintf(...) for the same task:

    var s = sprintf("%04d", yournumber);

    So apparently sprintf() isn’t standard Javascript but is a library you can download if you like. You can always to do this to get your 4 digits though:

    // take the last 4 digits from the right
    var s = String("0000" + yournumber).slice(-4); 
    

    And you could actually turn this into a simple left-padding function:

    String.prototype.leftPad = function(paddingValue, paddingLength) {
       return (new Array(paddingLength + 1).join(paddingValue) + this).slice(-paddingLength);
    };
    
    var s = String(yournumber).leftPad("0", 4)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database that had several tables full of thousands of rows of
I have a table (table variable in-fact) that holds several thousand (50k approx) rows
I have several Delphi programs that maintain connections to a database (some Oracle, some
I have a table that contains several thousand rows, having a Varchar column that
In my SQL Server 2008 Enterprise I have a database that contains several tables:
I have an array that can hold up to several thousands of items.(usually around
I have a page with a table on it that has several thousand rows
I have several large csv files with thousands of columns that I need to
I have a grid with several thousand rows that can be filtered and sorted.
I have several thousand objects with a string property in the format of yyyy-MM-ddTHH:mm:ssZ

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.